]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485) (#126495)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 6 Nov 2024 13:51:39 +0000 (14:51 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Nov 2024 13:51:39 +0000 (13:51 +0000)
gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485)

Handle _Unpickler_SetStringInput() failure.
(cherry picked from commit a1c57bcfd2bcbc55ff858407e09c1d8d8cee44e6)

Co-authored-by: Victor Stinner <vstinner@python.org>
Modules/_pickle.c

index add07d558ab7b6e2c41e4ed505608cf5033ee00f..aa4e21781e23bd1e4c3b0cb1820e383362123384 100644 (file)
@@ -1287,6 +1287,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;