]> granicus.if.org Git - python/commitdiff
bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() (GH-9705)
authorZackery Spytz <zspytz@gmail.com>
Fri, 5 Oct 2018 21:02:23 +0000 (15:02 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 5 Oct 2018 21:02:23 +0000 (00:02 +0300)
The _PyLong_FromByteArray() call in int_from_bytes_impl() was
unchecked.

Objects/longobject.c

index afe30bc0532a786090c9ffd3bb27ab596311e11d..ae3a98cc791c9a48e62b9b050c139251154d24f5 100644 (file)
@@ -5403,7 +5403,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));
     }