]> granicus.if.org Git - python/commitdiff
bpo-34879: Fix a possible null pointer dereference in bytesobject.c (GH-9683)
authorZackery Spytz <zspytz@gmail.com>
Wed, 3 Oct 2018 06:01:30 +0000 (00:01 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 3 Oct 2018 06:01:30 +0000 (09:01 +0300)
formatfloat() was not checking if PyBytes_FromStringAndSize()
failed, which could lead to a null pointer dereference in
_PyBytes_FormatEx().

Misc/NEWS.d/next/Core and Builtins/2018-10-02-22-55-11.bpo-34879.7VNH2a.rst [new file with mode: 0644]
Objects/bytesobject.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-10-02-22-55-11.bpo-34879.7VNH2a.rst b/Misc/NEWS.d/next/Core and Builtins/2018-10-02-22-55-11.bpo-34879.7VNH2a.rst
new file mode 100644 (file)
index 0000000..5775a21
--- /dev/null
@@ -0,0 +1,2 @@
+Fix a possible null pointer dereference in bytesobject.c.  Patch by Zackery
+Spytz.
index fb344c1896ad29d9bd3f954b06135c4d42af7a34..d51d1ba023c3853ba1c67baf16b40f8fa42a2203 100644 (file)
@@ -448,7 +448,7 @@ formatfloat(PyObject *v, int flags, int prec, int type,
     result = PyBytes_FromStringAndSize(p, len);
     PyMem_Free(p);
     *p_result = result;
-    return str;
+    return result != NULL ? str : NULL;
 }
 
 static PyObject *