Trent Mick's Win64 changes: size_t vs. int or long; also some overflow

tests.
This commit is contained in:
Guido van Rossum 2000-06-28 22:07:35 +00:00
parent 6f2a5efec9
commit 582acece2e
9 changed files with 40 additions and 21 deletions

View file

@ -355,8 +355,15 @@ do_mkvalue(p_format, p_va)
Py_INCREF(v);
}
else {
if (n < 0)
n = strlen(str);
if (n < 0) {
size_t m = strlen(str);
if (m > INT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"string too long for Python string");
return NULL;
}
n = (int)m;
}
v = PyString_FromStringAndSize(str, n);
}
return v;