From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:51:39 +0000 (+0100) Subject: [3.13] gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485) (#126495) X-Git-Tag: v3.13.1~155 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83827ad81972e8e6438a29274dbdcb923d7b1cc4;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485) (#126495) gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485) Handle _Unpickler_SetStringInput() failure. (cherry picked from commit a1c57bcfd2bcbc55ff858407e09c1d8d8cee44e6) Co-authored-by: Victor Stinner --- diff --git a/Modules/_pickle.c b/Modules/_pickle.c index add07d558ab7..aa4e21781e23 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -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;