From bea0379830c349f224b1025c16c0c04f2deec7f6 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Sat, 22 May 2021 23:13:52 -0700 Subject: [PATCH] Fix off-by-one error in group search This could be hit when loading raze.pk3 from the build directory while the file search path contains only one grp file --- source/core/searchpaths.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index 56379464f..e6896dfc3 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -798,7 +798,7 @@ TArray GrpScan() int gindex = sortedGroupList.Size() - 1; - while (findex > 0 && gindex > 0) + while (findex >= 0 && gindex >= 0) { if (sortedFileList[findex]->FileLength > sortedGroupList[gindex]->size) { @@ -815,8 +815,8 @@ TArray GrpScan() findex--; gindex--; // We found a matching file. Skip over all other entries of the same size so we can analyze those later as well - while (findex > 0 && sortedFileList[findex]->FileLength == sortedFileList[findex + 1]->FileLength) findex--; - while (gindex > 0 && sortedGroupList[gindex]->size == sortedGroupList[gindex + 1]->size) gindex--; + while (findex >= 0 && sortedFileList[findex]->FileLength == sortedFileList[findex + 1]->FileLength) findex--; + while (gindex >= 0 && sortedGroupList[gindex]->size == sortedGroupList[gindex + 1]->size) gindex--; } } sortedFileList.Delete(0, findex + 1);