summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibPDF
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-20 17:01:39 +0000
committerAndreas Kling <kling@serenityos.org>2022-01-24 22:36:09 +0100
commitf590cd1850027399ab7f0193ba97fa76b3a9cbab (patch)
treec081315ec020ff956bd8cc62ab2549def75bcc9e /Userland/Libraries/LibPDF
parent45cf40653a03dab11c0739783446ff696a9a5b0a (diff)
downloadserenity-f590cd1850027399ab7f0193ba97fa76b3a9cbab.zip
AK+Userland: Make AK::decode_hex() return ErrorOr
This lets us propagate the reason why it failed up to the caller. :^)
Diffstat (limited to 'Userland/Libraries/LibPDF')
-rw-r--r--Userland/Libraries/LibPDF/Filter.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp
index f5c15fa326..929f78ffca 100644
--- a/Userland/Libraries/LibPDF/Filter.cpp
+++ b/Userland/Libraries/LibPDF/Filter.cpp
@@ -39,8 +39,12 @@ Optional<ByteBuffer> Filter::decode(ReadonlyBytes bytes, FlyString const& encodi
Optional<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes bytes)
{
- if (bytes.size() % 2 == 0)
- return decode_hex(bytes);
+ if (bytes.size() % 2 == 0) {
+ auto decode_result = decode_hex(bytes);
+ if (decode_result.is_error())
+ return {};
+ return decode_result.release_value();
+ }
// FIXME: Integrate this padding into AK/Hex?