From: Thomas Wouters Date: Tue, 7 Mar 2006 13:39:26 +0000 (+0000) Subject: Backport trunk's r42885 (thomas.wouters): X-Git-Tag: v2.4.3c1~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4fbad67edfdc60b438586d199221010c6e1bd663;p=thirdparty%2FPython%2Fcpython.git Backport trunk's r42885 (thomas.wouters): Coverity-found bug: don't use temp->next *before* checking it for NULL. Also return rather than use it again. --- diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index b5f30cb85efc..01243b837cb5 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -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;