[gamecode] Bail if PR_SearchDefs is given 0 defs

Fixes the hang when searching for a field in progs that don't have any.
This commit is contained in:
Bill Currie 2020-03-16 13:46:46 +09:00
parent c8e45c6cfc
commit b544a052bf
1 changed files with 3 additions and 0 deletions

View File

@ -51,6 +51,9 @@ PR_SearchDefs (pr_def_t *defs, unsigned num_defs, pointer_t offset)
unsigned right = num_defs - 1;
unsigned mid;
if (!num_defs) {
return 0;
}
while (left != right) {
mid = (left + right + 1) / 2;
if (defs[mid].ofs > offset) {