summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorRodrigo Tobar <rtobar@icrar.org>2022-12-15 00:48:42 +0800
committerAndreas Kling <kling@serenityos.org>2022-12-16 10:04:23 +0100
commitd4ecdf3ced5709d3ba98a5821ac919c45a8dff0a (patch)
treeccf06000e731e65036decaf6e6a222400deb9f8c /Userland
parent124ab5bec62fb0f116b6976d59c9706895222aac (diff)
downloadserenity-d4ecdf3ced5709d3ba98a5821ac919c45a8dff0a.zip
PDFViewer: Avoid errors due to copying of ErrorOr
The handle_error took PDFErrorOr<T> objects by value, meaning that their inner values (the error or value stored in the underlying Variant) were somehow copied over. In the first instance where this lambda is called with T = NonnullRefPtr, resulting in funky behavior (invalid NonnullRefPtr state with a VALIDATE fail): if there is no error then the PDFErrorOr<T> copy is destroyed, which might be causing the underlying NonnullRefPtr to be destroyed, but somehow the original in the caller context gets affected and fails verification. The solution seems simple anyway: just pass the value by reference (lvalue or rvalue) so the original object can be used directly, avoiding destruction.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
index ee552cd588..2f60ae1a4a 100644
--- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
+++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
@@ -338,7 +338,7 @@ void PDFViewerWidget::open_file(Core::File& file)
{
window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", file.filename()));
- auto handle_error = [&]<typename T>(PDF::PDFErrorOr<T> maybe_error) {
+ auto handle_error = [&](auto&& maybe_error) {
if (maybe_error.is_error()) {
auto error = maybe_error.release_error();
warnln("{}", error.message());