mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 18:28:57 +00: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: 0bc3333740
Pull-request: https://github.com/SerenityOS/serenity/pull/16015
Reviewed-by: https://github.com/mattco98 ✅
1 changed files with 2 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue