mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #18294: Fix uint_converter() in zlibmodule.c, fix the "> UINT_MAX" check
This commit is contained in:
parent
fbc785188d
commit
5c86733c8a
1 changed files with 6 additions and 5 deletions
|
|
@ -329,11 +329,6 @@ uint_converter(PyObject *obj, void *ptr)
|
||||||
uval = PyLong_AsUnsignedLong(obj);
|
uval = PyLong_AsUnsignedLong(obj);
|
||||||
if (uval == (unsigned long)-1 && PyErr_Occurred())
|
if (uval == (unsigned long)-1 && PyErr_Occurred())
|
||||||
return 0;
|
return 0;
|
||||||
if (uval > UINT_MAX) {
|
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
|
||||||
"Python int too large for C unsigned int");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
|
|
@ -344,6 +339,12 @@ uint_converter(PyObject *obj, void *ptr)
|
||||||
uval = (unsigned long)val;
|
uval = (unsigned long)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uval > UINT_MAX) {
|
||||||
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
"Python int too large for C unsigned int");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
*(unsigned int *)ptr = Py_SAFE_DOWNCAST(uval, unsigned long, unsigned int);
|
*(unsigned int *)ptr = Py_SAFE_DOWNCAST(uval, unsigned long, unsigned int);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue