]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126461: Fix _Unpickler_ReadFromFile() error handling (#126485)
authorVictor Stinner <vstinner@python.org>
Wed, 6 Nov 2024 13:24:46 +0000 (14:24 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Nov 2024 13:24:46 +0000 (14:24 +0100)
Handle _Unpickler_SetStringInput() failure.

Modules/_pickle.c

index b2bd9545c1b13048d84fc69747a0aa86d0679759..863da6878409f32719b33f432b86bf2b1936cc9f 100644 (file)
@@ -1288,6 +1288,10 @@ _Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)
             else {
                 read_size = _Unpickler_SetStringInput(self, data);
                 Py_DECREF(data);
+                if (read_size < 0) {
+                    return -1;
+                }
+
                 self->prefetched_idx = 0;
                 if (n <= read_size)
                     return n;