[3.14] gh-136053: Check error for TYPE_SLICE in marshal.c (GH-136054) (GH-136092)

Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.
(cherry picked from commit 30ba03ea8e)

Co-authored-by: Akshat Gupta <akshat.gupta24@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-06-29 09:36:04 +02:00 committed by GitHub
parent 7df3eee645
commit ce65956177
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -0,0 +1 @@
:mod:`marshal`: fix a possible crash when deserializing :class:`slice` objects.

View file

@ -1656,6 +1656,9 @@ r_object(RFILE *p)
case TYPE_SLICE:
{
Py_ssize_t idx = r_ref_reserve(flag, p);
if (idx < 0) {
break;
}
PyObject *stop = NULL;
PyObject *step = NULL;
PyObject *start = r_object(p);