[Python-checkins] bpo-34879: Fix a possible null pointer dereference in bytesobject.c (GH-9683)
Serhiy Storchaka
webhook-mailer at python.org
Wed Oct 3 02:01:35 EDT 2018
https://github.com/python/cpython/commit/96c593279400693226d5a560c420ae0fcf1731b9
commit: 96c593279400693226d5a560c420ae0fcf1731b9
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018-10-03T09:01:30+03:00
summary:
bpo-34879: Fix a possible null pointer dereference in bytesobject.c (GH-9683)
formatfloat() was not checking if PyBytes_FromStringAndSize()
failed, which could lead to a null pointer dereference in
_PyBytes_FormatEx().
files:
A Misc/NEWS.d/next/Core and Builtins/2018-10-02-22-55-11.bpo-34879.7VNH2a.rst
M 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
index 000000000000..5775a219a273
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-10-02-22-55-11.bpo-34879.7VNH2a.rst
@@ -0,0 +1,2 @@
+Fix a possible null pointer dereference in bytesobject.c. Patch by Zackery
+Spytz.
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index fb344c1896ad..d51d1ba023c3 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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 *
More information about the Python-checkins
mailing list