]> granicus.if.org Git - python/commitdiff
Fix bug #1512695: cPickle.loads could crash if it was interrupted with
authorNeal Norwitz <nnorwitz@gmail.com>
Wed, 28 Jun 2006 06:28:31 +0000 (06:28 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Wed, 28 Jun 2006 06:28:31 +0000 (06:28 +0000)
a KeyboardInterrupt since PyTuple_Pack was passed a NULL.

Will backport.

Misc/NEWS
Modules/cPickle.c

index cefa739602e990fb9a433ad16fca7af43953c533..efbb1453bf125d67d93330ce9b7c171bfecf66fe 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,12 @@ Library
 
 - The wsgiref package is now installed properly on Unix.
 
+Extension Modules
+-----------------
+
+- Bug #1512695: cPickle.loads could crash if it was interrupted with
+  a KeyboardInterrupt.
+
 Build
 -----
 
index 0d293627afe39157b1096f57f4a81ed711a237c7..6b9b322247ec3e820115e77fa8d023fb17eddc8a 100644 (file)
@@ -3628,10 +3628,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;
                }