1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

LibPDF: Don't crash on files with float CFF defaultWidthX

We'd unconditionally get the int from a Variant<int, float> here,
but PDFs often have a float for defaultWidthX and nominalWidthX.

Fixes crash opening Bakke2010a.pdf from pdffiles (but while the
file loads ok, it looks completely busted).
This commit is contained in:
Nico Weber 2023-10-12 11:25:16 -04:00 committed by Jelle Raaijmakers
parent e7c8ff3839
commit 349996f7f2
2 changed files with 15 additions and 6 deletions

View file

@ -56,6 +56,13 @@ public:
using SID = u16;
using DictOperand = Variant<int, float>;
static float to_number(DictOperand operand)
{
if (operand.has<int>())
return operand.get<int>();
return operand.get<float>();
}
static int load_int_dict_operand(u8 b0, Reader&);
static float load_float_dict_operand(Reader&);
static PDFErrorOr<DictOperand> load_dict_operand(u8, Reader&);