[New-bugs-announce] [issue18295] Possible integer overflow in PyCode_New()

STINNER Victor report at bugs.python.org
Mon Jun 24 23:19:05 CEST 2013


New submission from STINNER Victor:

On Windows x64, we get the following warning:

..\Objects\codeobject.c(106): warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data [C:\buildbot.python.org\3.x.kloth-win64\build\PCbuild\pythoncore.vcxproj]

Code:

            unsigned char *cell2arg = NULL;
            Py_ssize_t total_args = argcount + kwonlyargcount +
            ((flags & CO_VARARGS) != 0) + ((flags & CO_VARKEYWORDS) != 0);
            PyObject *cell = PyTuple_GET_ITEM(cellvars, i);
            for (j = 0; j < total_args; j++) {
                PyObject *arg = PyTuple_GET_ITEM(varnames, j);
                if (!PyUnicode_Compare(cell, arg)) {
      ====>         cell2arg[i] = j; <===== HERE
                    used_cell2arg = 1;
                    break;
                }
            }

total_args is not checked for being smaller than 256.

Related issue: #9566.

----------
components: Interpreter Core
messages: 191805
nosy: haypo
priority: normal
severity: normal
status: open
title: Possible integer overflow in PyCode_New()
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18295>
_______________________________________


More information about the New-bugs-announce mailing list