[Python-checkins] cpython: Issue #18408: Fix PyCode_Optimize(): raise a MemoryError on memory allocation
victor.stinner
python-checkins at python.org
Tue Jul 9 00:53:50 CEST 2013
http://hg.python.org/cpython/rev/a45407fa4a5b
changeset: 84519:a45407fa4a5b
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jul 09 00:32:04 2013 +0200
summary:
Issue #18408: Fix PyCode_Optimize(): raise a MemoryError on memory allocation
failure.
files:
Python/peephole.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Python/peephole.c b/Python/peephole.c
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -381,8 +381,10 @@
/* Make a modifiable copy of the code string */
codestr = (unsigned char *)PyMem_Malloc(codelen);
- if (codestr == NULL)
+ if (codestr == NULL) {
+ PyErr_NoMemory();
goto exitError;
+ }
codestr = (unsigned char *)memcpy(codestr,
PyBytes_AS_STRING(code), codelen);
@@ -396,8 +398,10 @@
/* Mapping to new jump targets after NOPs are removed */
addrmap = (int *)PyMem_Malloc(codelen * sizeof(int));
- if (addrmap == NULL)
+ if (addrmap == NULL) {
+ PyErr_NoMemory();
goto exitError;
+ }
blocks = markblocks(codestr, codelen);
if (blocks == NULL)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list