From: Zackery Spytz <zspytz@gmail.com>
Date: Fri, 5 Oct 2018 21:02:23 +0000 (-0600)
Subject: bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() (GH-9705)
X-Git-Tag: v3.8.0a1~827
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bb9cd0a6766fd3e7b3c1e8f2315304ae192b34c;p=python

bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() (GH-9705)

The _PyLong_FromByteArray() call in int_from_bytes_impl() was
unchecked.
---

diff --git a/Objects/longobject.c b/Objects/longobject.c
index afe30bc053..ae3a98cc79 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -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));
     }