]> granicus.if.org Git - python/commitdiff
bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier.
authorGeorg Brandl <georg@python.org>
Wed, 12 Sep 2007 18:29:21 +0000 (18:29 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 12 Sep 2007 18:29:21 +0000 (18:29 +0000)
 (backport from rev. 58119)

Mac/Modules/cf/_CFmodule.c
Mac/Modules/cf/cfsupport.py
Mac/Modules/cf/pycfbridge.c

index 3f4d4f264eae4fde667971dbc16f1750e80d530d..0904ae100ee2b505b39f03f8654df4a795fdd7dd 100644 (file)
@@ -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)) {
index 800581a03e353466cf81c5c07eddc7fbacff67f1..c10a85eedb33e0821996de9ab7503fe3464ec97c 100644 (file)
@@ -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)) {
index ae9e128eac7cf4a474bb3ec2b040159471cc299a..06700b365fdc9166f321f190e3ed3249e438c938 100644 (file)
@@ -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)) {