summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-09-12 18:29:21 (GMT)
committerGeorg Brandl <georg@python.org>2007-09-12 18:29:21 (GMT)
commit226910f52d94beededad90e9de644c0da663d72a (patch)
tree0b2f10dfc2b572e0c57996140f2098b4ffdf0c6f /Mac
parentb8c23fb5fe5f571f91ac1286c9f383c2f201b670 (diff)
downloadcpython-226910f52d94beededad90e9de644c0da663d72a.zip
cpython-226910f52d94beededad90e9de644c0da663d72a.tar.gz
cpython-226910f52d94beededad90e9de644c0da663d72a.tar.bz2
bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier.
(backport from rev. 58119)
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/cf/_CFmodule.c1
-rw-r--r--Mac/Modules/cf/cfsupport.py1
-rw-r--r--Mac/Modules/cf/pycfbridge.c1
3 files changed, 3 insertions, 0 deletions
diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c
index 3f4d4f2..0904ae1 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 800581a..c10a85e 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 ae9e128..06700b3 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)) {