]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() (GH-9705)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 5 Oct 2018 21:28:56 +0000 (14:28 -0700)
committerGitHub <noreply@github.com>
Fri, 5 Oct 2018 21:28:56 +0000 (14:28 -0700)
The _PyLong_FromByteArray() call in int_from_bytes_impl() was
unchecked.
(cherry picked from commit 7bb9cd0a6766fd3e7b3c1e8f2315304ae192b34c)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Objects/longobject.c

index 269d6cdea590ff1679f579aaac910d2c54e479a3..59c7efbfee2e1489fc1f3263264d35c5874381fb 100644 (file)
@@ -5270,7 +5270,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj,
         little_endian, is_signed);
     Py_DECREF(bytes);
 
-    if (type != &PyLong_Type) {
+    if (long_obj != NULL && type != &PyLong_Type) {
         Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type,
                                                          long_obj, NULL));
     }