From: Georg Brandl Date: Wed, 12 Sep 2007 18:29:21 +0000 (+0000) Subject: bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier. X-Git-Tag: v2.5.2c1~185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=226910f52d94beededad90e9de644c0da663d72a;p=python bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier. (backport from rev. 58119) --- diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index 3f4d4f264e..0904ae100e 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -1828,6 +1828,7 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) if (!PyArg_Parse(v, "es", "ascii", &cStr)) return 0; *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); + PyMem_Free(cStr); return 1; } if (PyUnicode_Check(v)) { diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index 800581a03e..c10a85eedb 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -429,6 +429,7 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition): if (!PyArg_Parse(v, "es", "ascii", &cStr)) return NULL; *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); + PyMem_Free(cStr); return 1; } if (PyUnicode_Check(v)) { diff --git a/Mac/Modules/cf/pycfbridge.c b/Mac/Modules/cf/pycfbridge.c index ae9e128eac..06700b365f 100644 --- a/Mac/Modules/cf/pycfbridge.c +++ b/Mac/Modules/cf/pycfbridge.c @@ -285,6 +285,7 @@ PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) { if (!PyArg_Parse(src, "es", "ascii", &chars)) return 0; /* This error is more descriptive than the general one below */ *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII); + PyMem_Free(chars); return 1; } if (PyUnicode_Check(src)) {