]> granicus.if.org Git - python/commitdiff
Coverity-found bug: don't use temp->next *before* checking it for NULL. Also
authorThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 13:38:14 +0000 (13:38 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 13:38:14 +0000 (13:38 +0000)
return rather than use it again.

Modules/_curses_panel.c

index c3f313a33483d4719dec4f67a88cd99c805a63b4..0acf3fdee82d436ee100136601240e22b177a1c0 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;