diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-11 22:53:57 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-11 22:53:57 (GMT) |
commit | 4202456cd4dfb19e04a1a08b210d99933c1e024e (patch) | |
tree | 3c71fba7a76f7dd429d5e1d08d822c9ea16b5cc1 /Modules/_pickle.c | |
parent | 8ca72e2e3dfd0643288c27c4462cb8be62b5b049 (diff) | |
download | cpython-4202456cd4dfb19e04a1a08b210d99933c1e024e.zip cpython-4202456cd4dfb19e04a1a08b210d99933c1e024e.tar.gz cpython-4202456cd4dfb19e04a1a08b210d99933c1e024e.tar.bz2 |
Issue #18408: _pickle.c: Add missing PyErr_NoMemory() on memory allocation failures
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 888a498..e7d7dd9 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -436,6 +436,7 @@ PyMemoTable_Copy(PyMemoTable *self) new->mt_table = PyMem_MALLOC(self->mt_allocated * sizeof(PyMemoEntry)); if (new->mt_table == NULL) { PyMem_FREE(new); + PyErr_NoMemory(); return NULL; } for (i = 0; i < self->mt_allocated; i++) { @@ -1003,8 +1004,10 @@ _Unpickler_CopyLine(UnpicklerObject *self, char *line, Py_ssize_t len, char **result) { char *input_line = PyMem_Realloc(self->input_line, len + 1); - if (input_line == NULL) + if (input_line == NULL) { + PyErr_NoMemory(); return -1; + } memcpy(input_line, line, len); input_line[len] = '\0'; @@ -1101,8 +1104,10 @@ static PyObject ** _Unpickler_NewMemo(Py_ssize_t new_size) { PyObject **memo = PyMem_MALLOC(new_size * sizeof(PyObject *)); - if (memo == NULL) + if (memo == NULL) { + PyErr_NoMemory(); return NULL; + } memset(memo, 0, new_size * sizeof(PyObject *)); return memo; } |