Commit 9e0417c3 authored by Stefan Behnel's avatar Stefan Behnel

fix implicit integer downcast in __Pyx_PyByteArray_AppendObject() function

parent b8d5519e
...@@ -699,9 +699,14 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO ...@@ -699,9 +699,14 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO
} else } else
#endif #endif
{ {
// CPython calls PyNumber_Index() internally
ival = __Pyx_PyIndex_AsSsize_t(value); ival = __Pyx_PyIndex_AsSsize_t(value);
if (unlikely(ival == -1 && PyErr_Occurred())) if (unlikely((ival < 0) | (ival > 255))) {
if (ival == -1 && PyErr_Occurred())
return -1;
PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
return -1; return -1;
}
} }
return __Pyx_PyByteArray_Append(bytearray, ival); return __Pyx_PyByteArray_Append(bytearray, ival);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment