mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibPDF: Parse integer numbers with atoi() instead of strtof()
strtof() produces rounding errors for very large numbers, which we don't want for integers, as they may have to be precise.
This commit is contained in:
parent
c2ad29c85f
commit
0bc3333740
Notes:
sideshowbarker
2024-07-17 06:35:23 +09:00
Author: https://github.com/janso3 Commit: https://github.com/SerenityOS/serenity/commit/0bc3333740 Pull-request: https://github.com/SerenityOS/serenity/pull/16015 Reviewed-by: https://github.com/mattco98 ✅
@ -194,12 +194,10 @@ PDFErrorOr<Value> Parser::parse_number()
|
||||
m_reader.consume_whitespace();
|
||||
|
||||
auto string = String(m_reader.bytes().slice(start_offset, m_reader.offset() - start_offset));
|
||||
float f = strtof(string.characters(), nullptr);
|
||||
if (is_float)
|
||||
return Value(f);
|
||||
return Value(strtof(string.characters(), nullptr));
|
||||
|
||||
VERIFY(floorf(f) == f);
|
||||
return Value(static_cast<int>(f));
|
||||
return Value(atoi(string.characters()));
|
||||
}
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<NameObject>> Parser::parse_name()
|
||||
|
Loading…
Reference in New Issue
Block a user