diff --git a/Modules/_pickle.c b/Modules/_pickle.c index add07d558ab7b6..aa4e21781e23bd 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;