diff Modules/cPickle.c @ 38949:56bf56f5c821 legacy-trunk

Fix bug #1512695: cPickle.loads could crash if it was interrupted with a KeyboardInterrupt since PyTuple_Pack was passed a NULL. Will backport.
author Neal Norwitz <nnorwitz@gmail.com>
date Wed, 28 Jun 2006 06:28:31 +0000
parents 3fe3ccdf0155
children 12e973bdfeee
line wrap: on
line diff
--- a/Modules/cPickle.c	Wed Jun 28 05:03:22 2006 +0000
+++ b/Modules/cPickle.c	Wed Jun 28 06:28:31 2006 +0000
@@ -3628,10 +3628,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;
 		}