Resolve out-of-bounds access at start of level 10

Descent3/aipath.cpp:663:40: runtime error: index -1 out of bounds for type
'short unsigned int [5]'
This commit is contained in:
Jan Engelhardt 2024-09-01 16:14:46 +02:00
parent 10a03e71ef
commit bb1d6f6f85

View File

@ -651,6 +651,8 @@ static inline bool AIPathAddDPathNode(ai_path_info *aip, int *slot, int *cur_nod
status = AIPathAddDPath(aip, handle);
if (!status)
Int3(); // chrishack -- out of dynamic paths
if (aip->num_paths < 1)
return false;
AIDynamicPath[*slot].num_nodes = MAX_NODES;
*cur_node = 0;
@ -660,7 +662,8 @@ static inline bool AIPathAddDPathNode(ai_path_info *aip, int *slot, int *cur_nod
AIDynamicPath[*slot].pos[*cur_node] = *pos;
AIDynamicPath[*slot].roomnum[(*cur_node)++] = room;
aip->path_end_node[aip->num_paths - 1] = *cur_node - 1;
if (aip->num_paths >= 0)
aip->path_end_node[aip->num_paths - 1] = *cur_node - 1;
return true;
}