[Python-checkins] cpython: Issue #19429, #19437: fix error handling in the OSError constructor

victor.stinner python-checkins at python.org
Thu Nov 14 22:56:36 CET 2013


http://hg.python.org/cpython/rev/61a712066770
changeset:   87106:61a712066770
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Nov 14 22:31:41 2013 +0100
summary:
  Issue #19429, #19437: fix error handling in the OSError constructor

files:
  Objects/exceptions.c |  10 ++++++----
  1 files changed, 6 insertions(+), 4 deletions(-)


diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -845,7 +845,7 @@
     /* Steals the reference to args */
     Py_CLEAR(self->args);
     self->args = args;
-    args = NULL;
+    *p_args = args = NULL;
 
     return 0;
 }
@@ -885,11 +885,12 @@
     PyObject *winerror = NULL;
 #endif
 
+    Py_INCREF(args);
+
     if (!oserror_use_init(type)) {
         if (!_PyArg_NoKeywords(type->tp_name, kwds))
-            return NULL;
-
-        Py_INCREF(args);
+            goto error;
+
         if (oserror_parse_args(&args, &myerrno, &strerror, &filename
 #ifdef MS_WINDOWS
                                , &winerror
@@ -932,6 +933,7 @@
             goto error;
     }
 
+    Py_XDECREF(args);
     return (PyObject *) self;
 
 error:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list