mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
This commit is contained in:
parent
6f2a5efec9
commit
582acece2e
9 changed files with 40 additions and 21 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue