LibPDF: Convert byte offsets to u64

This fixes a build failure on 32-bit.

Suggested-by: Nico Weber <thakis@chromium.org>
This commit is contained in:
Sergey Bugaev 2024-04-24 17:02:51 +03:00 committed by Andrew Kaster
commit d458471e09
Notes: sideshowbarker 2024-07-17 02:23:25 +09:00
3 changed files with 8 additions and 8 deletions

View file

@ -477,7 +477,7 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream()
Vector<XRefEntry> entries;
for (int i = 0; i < count; i++) {
Array<long, 3> fields;
Array<u64, 3> fields;
for (size_t field_index = 0; field_index < 3; ++field_index) {
if (!field_sizes->at(field_index).has_u32())
return error("Malformed xref stream");
@ -562,7 +562,7 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_table()
m_reader.move_by(2);
}
auto offset = strtol(offset_string.characters(), nullptr, 10);
u64 offset = strtoll(offset_string.characters(), nullptr, 10);
auto generation = strtol(generation_string.characters(), nullptr, 10);
entries.append({ offset, static_cast<u16>(generation), letter == 'n' });

View file

@ -156,7 +156,7 @@ SampledFunction::create(Document* document, Vector<Bound> domain, Optional<Vecto
size_product *= size;
size_t bits_per_plane = size_product * bits_per_sample;
size_t total_bits = bits_per_plane * decode.size();
if (stream->bytes().size() < ceil_div(total_bits, 8ull))
if (stream->bytes().size() < ceil_div(total_bits, static_cast<size_t>(8)))
return Error { Error::Type::MalformedPDF, "Function type 0 stream too small" };
auto function = adopt_ref(*new SampledFunction(stream));

View file

@ -14,10 +14,10 @@
namespace PDF {
constexpr long invalid_byte_offset = NumericLimits<long>::max();
constexpr u64 invalid_byte_offset = NumericLimits<u64>::max();
struct XRefEntry {
long byte_offset { invalid_byte_offset };
u64 byte_offset { invalid_byte_offset };
u16 generation_number { 0 };
bool in_use { false };
bool compressed { false };
@ -73,16 +73,16 @@ public:
[[nodiscard]] ALWAYS_INLINE bool has_object(size_t index) const
{
return index < m_entries.size() && m_entries[index].byte_offset != -1;
return index < m_entries.size() && m_entries[index].byte_offset != invalid_byte_offset;
}
[[nodiscard]] ALWAYS_INLINE long byte_offset_for_object(size_t index) const
[[nodiscard]] ALWAYS_INLINE u64 byte_offset_for_object(size_t index) const
{
VERIFY(has_object(index));
return m_entries[index].byte_offset;
}
[[nodiscard]] ALWAYS_INLINE long object_stream_for_object(size_t index) const
[[nodiscard]] ALWAYS_INLINE u64 object_stream_for_object(size_t index) const
{
return byte_offset_for_object(index);
}