fixed NULL check from getNextEntry

This commit is contained in:
Partho
2025-03-31 20:31:53 -04:00
parent 188c734465
commit c61a87634c

View File

@ -1221,7 +1221,17 @@ ListOfTable *getRestOfChildren(ListOfTable *lt) { return lt->next; }
TableNode *getFirstEntry(SymbolTable *st) { return st->entries; }
// Segfaults when passed an invalid table node!
TableNode *getNextEntry(TableNode *tn) { return tn; }
TableNode *getNextEntry(TableNode *tn) {
if (tn == NULL) {
printdebug("passed a NULL table node to getNextEntry");
return undefined;
}
if (tn == undefined) {
printdebug("passed an undefined table node to getNextEntry");
return undefined;
}
return tn->next;
}
// uncomment the below main function along with the headers above for a simple