]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 47139:
authorNeal Norwitz <nnorwitz@gmail.com>
Wed, 28 Jun 2006 06:38:25 +0000 (06:38 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Wed, 28 Jun 2006 06:38:25 +0000 (06:38 +0000)
Fix bug #1512695: cPickle.loads could crash if it was interrupted with
a KeyboardInterrupt since PyTuple_Pack was passed a NULL.

Misc/NEWS
Modules/cPickle.c

index a4c1864c2b3589c7a964ba340a61a016dd89282a..5753cdc4f907004cd910692c76774d2ea0127ad7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -26,6 +26,9 @@ Core and builtins
 Extension Modules
 -----------------
 
+- Bug #1512695: cPickle.loads could crash if it was interrupted with
+  a KeyboardInterrupt.
+
 - Change binascii.hexlify() to accept any read-only buffer and not just a char
   buffer.
 
index e4f33c16272f6fb74ae8b5aaad413900cdba4e09..6465139f09b05134bdaee608f65f475b3bb83c9f 100644 (file)
@@ -3633,10 +3633,14 @@ Instance_New(PyObject *cls, PyObject *args)
 
   err:
        {
-               PyObject *tp, *v, *tb;
+               PyObject *tp, *v, *tb, *tmp_value;
 
                PyErr_Fetch(&tp, &v, &tb);
-               if ((r=PyTuple_Pack(3,v,cls,args))) {
+               tmp_value = v;
+               /* NULL occurs when there was a KeyboardInterrupt */
+               if (tmp_value == NULL)
+                       tmp_value = Py_None;
+               if ((r = PyTuple_Pack(3, tmp_value, cls, args))) {
                        Py_XDECREF(v);
                        v=r;
                }