Be more defensive when interacting with the path node stacks
This commit is contained in:
parent
f01d551eb0
commit
097a519bb7
1 changed files with 5 additions and 6 deletions
|
|
@ -380,9 +380,9 @@ void path_set_coords(PATHNODE *pPath)
|
|||
*/
|
||||
void path_push_active_step(PATHNODE *pPath)
|
||||
{
|
||||
int stackIndex = gdwCurPathStep;
|
||||
assert(gdwCurPathStep < MAXPATHNODES);
|
||||
pnode_tblptr[gdwCurPathStep] = pPath;
|
||||
gdwCurPathStep++;
|
||||
pnode_tblptr[stackIndex] = pPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -391,6 +391,7 @@ void path_push_active_step(PATHNODE *pPath)
|
|||
PATHNODE *path_pop_active_step()
|
||||
{
|
||||
gdwCurPathStep--;
|
||||
assert(gdwCurPathStep >= 0);
|
||||
return pnode_tblptr[gdwCurPathStep];
|
||||
}
|
||||
|
||||
|
|
@ -399,12 +400,10 @@ PATHNODE *path_pop_active_step()
|
|||
*/
|
||||
PATHNODE *path_new_step()
|
||||
{
|
||||
PATHNODE *newNode;
|
||||
|
||||
if (gdwCurNodes == MAXPATHNODES)
|
||||
if (gdwCurNodes >= MAXPATHNODES)
|
||||
return nullptr;
|
||||
|
||||
newNode = &path_nodes[gdwCurNodes];
|
||||
PATHNODE *newNode = &path_nodes[gdwCurNodes];
|
||||
gdwCurNodes++;
|
||||
memset(newNode, 0, sizeof(PATHNODE));
|
||||
return newNode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue