]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport SF bug #1004088:
authorRaymond Hettinger <python@rcn.com>
Fri, 6 Aug 2004 21:29:22 +0000 (21:29 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 6 Aug 2004 21:29:22 +0000 (21:29 +0000)
    big code objects (>64K) may be optimized incorrectly

Python/compile.c

index f2e04b00c1b004ef08aea25f80174416d735450b..21cea42f7ef5580d63f3d95750e98b8aa94f6266 100644 (file)
@@ -345,6 +345,10 @@ optimize_code(PyObject *code, PyObject* consts)
        codestr = memcpy(codestr, PyString_AS_STRING(code), codelen);
        assert(PyTuple_Check(consts));
 
+       /* Avoid situations where jump retargeting could overflow */
+       if (codelen > 65000)
+               goto exitUnchanged;
+
        for (i=0 ; i<codelen-7 ; i += HAS_ARG(codestr[i]) ? 3 : 1) {
                opcode = codestr[i];
                switch (opcode) {