summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-10-02 23:33:42 -0700
committerGitHub <noreply@github.com>2018-10-02 23:33:42 -0700
commit063755c20184e80f587d522600536d1ba70a5f7e (patch)
tree8ef81dc95639893c6f50b4d2e2522fbd669107af /Objects
parent97f998a4dfd6db6d867f446daa62445d0782bf39 (diff)
downloadcpython-git-063755c20184e80f587d522600536d1ba70a5f7e.tar.gz
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(). (cherry picked from commit 96c593279400693226d5a560c420ae0fcf1731b9) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 82a7545770..32ff5afe3e 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 *