gh-148653: Fix SIGSEGV in marshal.loads for self-referencing tuples

This commit is contained in:
Michael Bommarito 2026-04-16 13:40:35 -04:00
parent 2faceeec5c
commit 7c214ea52e
3 changed files with 26 additions and 1 deletions

View file

@ -1385,7 +1385,9 @@ r_object(RFILE *p)
}
_read_tuple:
v = PyTuple_New(n);
R_REF(v);
idx = r_ref_reserve(flag, p);
if (idx < 0)
Py_CLEAR(v);
if (v == NULL)
break;
@ -1400,6 +1402,7 @@ r_object(RFILE *p)
}
PyTuple_SET_ITEM(v, i, v2);
}
v = r_ref_insert(v, idx, flag, p);
retval = v;
break;