summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-10-03 06:01:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-03 06:01:30 (GMT)
commit96c593279400693226d5a560c420ae0fcf1731b9 (patch)
tree47d5c1567cbee5529cb1353286077bd8e6bb3ed5 /Objects/bytesobject.c
parente006b39a40e0cd6a90c68f1107853ea2ed0ed54d (diff)
downloadcpython-96c593279400693226d5a560c420ae0fcf1731b9.zip
cpython-96c593279400693226d5a560c420ae0fcf1731b9.tar.gz
cpython-96c593279400693226d5a560c420ae0fcf1731b9.tar.bz2
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().
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index fb344c1..d51d1ba 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 *