[Python-checkins] r47140 - in python/branches/release24-maint: Misc/NEWS Modules/cPickle.c

neal.norwitz python-checkins at python.org
Wed Jun 28 08:38:26 CEST 2006


Author: neal.norwitz
Date: Wed Jun 28 08:38:25 2006
New Revision: 47140

Modified:
   python/branches/release24-maint/Misc/NEWS
   python/branches/release24-maint/Modules/cPickle.c
Log:
Backport 47139:

Fix bug #1512695: cPickle.loads could crash if it was interrupted with
a KeyboardInterrupt since PyTuple_Pack was passed a NULL.



Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Wed Jun 28 08:38:25 2006
@@ -26,6 +26,9 @@
 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.
 

Modified: python/branches/release24-maint/Modules/cPickle.c
==============================================================================
--- python/branches/release24-maint/Modules/cPickle.c	(original)
+++ python/branches/release24-maint/Modules/cPickle.c	Wed Jun 28 08:38:25 2006
@@ -3633,10 +3633,14 @@
 
   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;
 		}


More information about the Python-checkins mailing list