Skip to content

Commit 5e93eed

Browse files
author
neal.norwitz
committed
Fix bug #1512695: cPickle.loads could crash if it was interrupted with
a KeyboardInterrupt since PyTuple_Pack was passed a NULL. Will backport. git-svn-id: http://svn.python.org/projects/python/trunk@47139 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 6538b85 commit 5e93eed

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Library
2828

2929
- The wsgiref package is now installed properly on Unix.
3030

31+
Extension Modules
32+
-----------------
33+
34+
- Bug #1512695: cPickle.loads could crash if it was interrupted with
35+
a KeyboardInterrupt.
36+
3137
Build
3238
-----
3339

Modules/cPickle.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,10 +3628,14 @@ Instance_New(PyObject *cls, PyObject *args)
36283628

36293629
err:
36303630
{
3631-
PyObject *tp, *v, *tb;
3631+
PyObject *tp, *v, *tb, *tmp_value;
36323632

36333633
PyErr_Fetch(&tp, &v, &tb);
3634-
if ((r=PyTuple_Pack(3,v,cls,args))) {
3634+
tmp_value = v;
3635+
/* NULL occurs when there was a KeyboardInterrupt */
3636+
if (tmp_value == NULL)
3637+
tmp_value = Py_None;
3638+
if ((r = PyTuple_Pack(3, tmp_value, cls, args))) {
36353639
Py_XDECREF(v);
36363640
v=r;
36373641
}

0 commit comments

Comments
 (0)