unsigned int *blocks;
char *name;
- /* Make a modifiable copy of the code string */
if (!PyString_Check(code))
goto exitUnchanged;
+
+ /* Avoid situations where jump retargeting could overflow */
codelen = PyString_Size(code);
+ if (codelen > 32000)
+ goto exitUnchanged;
+
+ /* Make a modifiable copy of the code string */
codestr = PyMem_Malloc(codelen);
if (codestr == NULL)
goto exitUnchanged;
if (addrmap == NULL)
goto exitUnchanged;
- /* Avoid situations where jump retargeting could overflow */
- if (codelen > 32000)
- goto exitUnchanged;
-
blocks = markblocks(codestr, codelen);
if (blocks == NULL)
goto exitUnchanged;
break;
case EXTENDED_ARG:
- PyMem_Free(codestr);
goto exitUnchanged;
/* Replace RETURN LOAD_CONST None RETURN with just RETURN */
}
/* Fixup linenotab */
+ /* XXX make sure this handles intervals > 256 */
assert(PyString_Check(lineno_obj));
lineno = PyString_AS_STRING(lineno_obj);
tabsiz = PyString_GET_SIZE(lineno_obj);
while (adj--)
codestr[h++] = codestr[i++];
}
+ assert(h + nops == codelen);
code = PyString_FromStringAndSize((char *)codestr, h);
PyMem_Free(addrmap);