From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:12:52 +0000 (-0800) Subject: gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057) X-Git-Tag: v3.10.10~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=664141e34c4df3aed6c21996e2476175d136c06b;p=thirdparty%2FPython%2Fcpython.git gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (GH-101057) (cherry picked from commit b1a74a182d8762bda51838401ac92b6ebad9632a) Co-authored-by: Nikita Sobolev --- diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index eaedb0b5689b..4bcb2eb49298 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -470,8 +470,10 @@ formatfloat(PyObject *v, int flags, int prec, int type, len = strlen(p); if (writer != NULL) { str = _PyBytesWriter_Prepare(writer, str, len); - if (str == NULL) + if (str == NULL) { + PyMem_Free(p); return NULL; + } memcpy(str, p, len); PyMem_Free(p); str += len;