Kaydet (Commit) 07752aba authored tarafından Georg Brandl's avatar Georg Brandl

bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier.

üst 5a25fcd5
...@@ -1828,6 +1828,7 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) ...@@ -1828,6 +1828,7 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
if (!PyArg_Parse(v, "es", "ascii", &cStr)) if (!PyArg_Parse(v, "es", "ascii", &cStr))
return 0; return 0;
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
PyMem_Free(cStr);
return 1; return 1;
} }
if (PyUnicode_Check(v)) { if (PyUnicode_Check(v)) {
......
...@@ -429,6 +429,7 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ...@@ -429,6 +429,7 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
if (!PyArg_Parse(v, "es", "ascii", &cStr)) if (!PyArg_Parse(v, "es", "ascii", &cStr))
return NULL; return NULL;
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
PyMem_Free(cStr);
return 1; return 1;
} }
if (PyUnicode_Check(v)) { if (PyUnicode_Check(v)) {
......
...@@ -285,6 +285,7 @@ PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) { ...@@ -285,6 +285,7 @@ PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) {
if (!PyArg_Parse(src, "es", "ascii", &chars)) if (!PyArg_Parse(src, "es", "ascii", &chars))
return 0; /* This error is more descriptive than the general one below */ return 0; /* This error is more descriptive than the general one below */
*dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII); *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII);
PyMem_Free(chars);
return 1; return 1;
} }
if (PyUnicode_Check(src)) { if (PyUnicode_Check(src)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment