From a939eea831f45c426406640b4a08428ef8a13815 Mon Sep 17 00:00:00 2001 From: Symmetricity <184246+Symmetricity@users.noreply.github.com> Date: Sun, 10 May 2026 16:10:54 +0200 Subject: [PATCH] Fix PBF block offsets on Windows PBF block offsets were stored as long int after casting from tellg(). On Windows, long remains 32-bit even in 64-bit builds, so offsets past 2GB can be truncated before later seekg() calls reread the block. Store the offset as std::streamoff instead, matching the stream offset type used by tellg()/seekg(). This keeps the existing block metadata flow but avoids narrowing large PBF positions. This matches the failure pattern reported in #776, where Windows builds crash when reading extracts just over the signed 32-bit boundary. Checked with make tilemaker -j2, make test_pbf_reader -j2, cmake --build build --target tilemaker -j2, and a MinGW Windows build smoke-tested with wine --help. --- include/pbf_processor.h | 3 ++- src/pbf_processor.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pbf_processor.h b/include/pbf_processor.h index ae555865..abd43bc6 100644 --- a/include/pbf_processor.h +++ b/include/pbf_processor.h @@ -3,6 +3,7 @@ #define _READ_PBF_H #include +#include #include #include #include @@ -20,7 +21,7 @@ extern const std::string OptionSortTypeThenID; extern const std::string OptionLocationsOnWays; struct BlockMetadata { - long int offset; + std::streamoff offset; int32_t length; bool hasNodes; bool hasWays; diff --git a/src/pbf_processor.cpp b/src/pbf_processor.cpp index 61147944..cea28bb7 100644 --- a/src/pbf_processor.cpp +++ b/src/pbf_processor.cpp @@ -538,7 +538,7 @@ int PbfProcessor::ReadPbfFile( break; } - blocks[blocks.size()] = { (long int)infile->tellg(), bh.datasize, true, true, true, 0, 1 }; + blocks[blocks.size()] = { static_cast(infile->tellg()), bh.datasize, true, true, true, 0, 1 }; infile->seekg(bh.datasize, std::ios_base::cur); }