Skip to content

Commit 30ba03e

Browse files
authored
gh-136053: Check error for TYPE_SLICE in marshal.c (GH-136054)
Fix a possible crash when deserializing a large marshal data (at least several GiBs) containing a slice.
1 parent f04d2b8 commit 30ba03e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:mod:`marshal`: fix a possible crash when deserializing :class:`slice` objects.

Python/marshal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,9 @@ r_object(RFILE *p)
16561656
case TYPE_SLICE:
16571657
{
16581658
Py_ssize_t idx = r_ref_reserve(flag, p);
1659+
if (idx < 0) {
1660+
break;
1661+
}
16591662
PyObject *stop = NULL;
16601663
PyObject *step = NULL;
16611664
PyObject *start = r_object(p);

0 commit comments

Comments
 (0)