From e323e0e91a27df127f53d24f2d741c2172e11233 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 29 Jun 2009 14:44:49 +0000 Subject: [PATCH] Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. --- Python/peephole.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Python/peephole.c b/Python/peephole.c index 13fc091032..fbc81ff993 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -305,7 +305,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Bail out if an exception is set */ if (PyErr_Occurred()) - goto exitUnchanged; + goto exitError; /* Bypass optimization when the lineno table is too complex */ assert(PyString_Check(lineno_obj)); @@ -323,7 +323,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Make a modifiable copy of the code string */ codestr = (unsigned char *)PyMem_Malloc(codelen); if (codestr == NULL) - goto exitUnchanged; + goto exitError; codestr = (unsigned char *)memcpy(codestr, PyString_AS_STRING(code), codelen); @@ -338,11 +338,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, /* Mapping to new jump targets after NOPs are removed */ addrmap = (int *)PyMem_Malloc(codelen * sizeof(int)); if (addrmap == NULL) - goto exitUnchanged; + goto exitError; blocks = markblocks(codestr, codelen); if (blocks == NULL) - goto exitUnchanged; + goto exitError; assert(PyList_Check(consts)); for (i=0 ; i