diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-03 11:26:12 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-03 11:26:12 (GMT) |
commit | 5c86733c8ab0817d3aea569592a0d6bfbee81e9c (patch) | |
tree | 12f412c46c578cc8ac8045f8eabc55f865cb1b18 /Modules/zlibmodule.c | |
parent | fbc785188db081c3d3940bf4dcd316de28fda066 (diff) | |
download | cpython-5c86733c8ab0817d3aea569592a0d6bfbee81e9c.zip cpython-5c86733c8ab0817d3aea569592a0d6bfbee81e9c.tar.gz cpython-5c86733c8ab0817d3aea569592a0d6bfbee81e9c.tar.bz2 |
Issue #18294: Fix uint_converter() in zlibmodule.c, fix the "> UINT_MAX" check
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r-- | Modules/zlibmodule.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index bf8c8e4..28ed3cd 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -329,11 +329,6 @@ uint_converter(PyObject *obj, void *ptr) uval = PyLong_AsUnsignedLong(obj); if (uval == (unsigned long)-1 && PyErr_Occurred()) return 0; - if (uval > UINT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "Python int too large for C unsigned int"); - return 0; - } } else { if (val < 0) { @@ -344,6 +339,12 @@ uint_converter(PyObject *obj, void *ptr) 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); return 1; } |