diff --git a/src/jrd/os/posix/unix.cpp b/src/jrd/os/posix/unix.cpp index 3c223f199a..1f6e124fb8 100644 --- a/src/jrd/os/posix/unix.cpp +++ b/src/jrd/os/posix/unix.cpp @@ -610,6 +610,9 @@ USHORT PIO_init_data(Database* dbb, jrd_file* main_file, ISC_STATUS* status_vect USHORT leftPages = initPages; const ULONG initBy = MIN(file->fil_max_page - startPage, leftPages); + if (initBy < leftPages) + leftPages = initBy; + for (ULONG i = startPage; i < startPage + initBy; ) { bdb.bdb_page = PageNumber(0, i); diff --git a/src/jrd/os/win32/winnt.cpp b/src/jrd/os/win32/winnt.cpp index 626b1142a4..a18cda4217 100644 --- a/src/jrd/os/win32/winnt.cpp +++ b/src/jrd/os/win32/winnt.cpp @@ -595,6 +595,9 @@ USHORT PIO_init_data(Database* dbb, jrd_file* main_file, ISC_STATUS* status_vect USHORT leftPages = initPages; const ULONG initBy = MIN(file->fil_max_page - startPage, leftPages); + if (initBy < leftPages) + leftPages = initBy; + for (ULONG i = startPage; i < startPage + initBy; ) { bdb.bdb_page = PageNumber(0, i);