Skip to content

Commit e2f376f

Browse files
bpo-34987: Fix a possible null pointer dereference in _pickle.c's save_reduce(). (GH-9886)
(cherry picked from commit 25d3897) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
1 parent 983d1ab commit e2f376f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/_pickle.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,10 @@ save_reduce(PicklerObject *self, PyObject *args, PyObject *obj)
38383838

38393839
if (obj != NULL) {
38403840
obj_class = get_class(obj);
3841-
p = obj_class != cls; /* true iff a problem */
3841+
if (obj_class == NULL) {
3842+
return -1;
3843+
}
3844+
p = obj_class != cls;
38423845
Py_DECREF(obj_class);
38433846
if (p) {
38443847
PyErr_SetString(st->PicklingError, "args[0] from "

0 commit comments

Comments
 (0)