ladybird/Userland
Nico Weber cafaaa0e76 LibPDF: Don't crash on zero-width characters in type1 fonts
Since ScaledFont bakes the size of the font into the font type, we
do the same for Type1 fonts, and then have to divide by the font height
when figuring out what to scale by. For a target width of 0, chances are
the source width is also 0, and we end up with NaN due to dividing
0 by 0. This then triggered the `VERIFY(isfinite(error))` in
can_approximate_bezier_curve() in Painter.cpp.

Check for this case and scale by 0 instead of dividing.

It could happen that the denominator is 0 without the numerator being 0,
but it's not clear what that's supposed to mean. In this case we'd end
up with +inf/-inf, which would also trigger the assert. I haven't seen
this case in practice, so let's not worry about that for now.

(A nicer longer-term fix is probably to make LibPDF use VectorFont
instead of ScaledFont, so that we don't have to bake the font size into
the font type. Then we won't need this division at all. In the meantime,
this fixes the crash.)

Fixes a crash on page 66 of
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf

Fixes a crash on page 37 of
https://open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

Fixes crashes in `0000310.pdf`, `0000430.pdf`, `0000229.pdf`.

Brings down the number of crashes on my 1000 file test set from
5 with 3 distinct stacks to 2 with 1 distinct stack.

(The number went up from 3 crashes with 2 distinct stacks to 5/3 when we
started rendering much more text when Type0 font support was added.
This fixes the crashes we had before Type0 support.)
2024-02-27 07:01:05 +01:00
..
Applets ClipboardHistory: Be more careful about the history limit 2024-02-08 13:46:12 +00:00
Applications Browser: Implement the <input type=file> UI 2024-02-26 14:18:49 +01:00
BuggieBox checksum: Add support for BLAKE2b 2023-09-17 16:49:35 +03:30
Demos Userland: Propagate errors with TRY() where possible 2024-02-14 17:46:06 -05:00
DevTools Userland: Propagate errors with TRY() where possible 2024-02-14 17:46:06 -05:00
DynamicLoader LibC: Separate arch dependent fenv functions 2024-01-22 20:06:09 -07:00
Games FlappyBug: Allow shortcuts for quitting and help 2024-02-19 00:09:34 +01:00
Libraries LibPDF: Don't crash on zero-width characters in type1 fonts 2024-02-27 07:01:05 +01:00
Services LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior 2024-02-26 14:18:49 +01:00
Shell Shell: Don't escape display/trailing texts when completing via programs 2024-02-07 00:43:11 +01:00
Utilities LibCore+Utilities: Replace ElapsedTimer precise flag with an enum 2024-02-26 16:12:20 -07:00
CMakeLists.txt