Coverity-found bug: don't use temp->next *before* checking it for NULL. Also

return rather than use it again.
This commit is contained in:
Thomas Wouters 2006-03-07 13:38:14 +00:00
parent 622927b850
commit 47f003d326
1 changed files with 4 additions and 2 deletions

View File

@ -111,10 +111,12 @@ remove_lop(PyCursesPanelObject *po)
free(temp);
return;
}
while (temp->next->po != po) {
if (temp->next == NULL)
while (temp->next == NULL || temp->next->po != po) {
if (temp->next == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"remove_lop: can't find Panel Object");
return;
}
temp = temp->next;
}
n = temp->next->next;