]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport trunk's r42885 (thomas.wouters):
authorThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 13:39:26 +0000 (13:39 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 13:39:26 +0000 (13:39 +0000)
Coverity-found bug: don't use temp->next *before* checking it for NULL. Also
return rather than use it again.

Modules/_curses_panel.c

index b5f30cb85efcbbe8156fef092ac3384a1e261f73..01243b837cb5068fda9bae6a250345426def476b 100644 (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;