Fix the memory leak related to Python 3 unicode and char * conversion.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11160 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
359c4f786d
commit
a863d31e81
6 changed files with 67 additions and 10 deletions
|
|
@ -55,11 +55,13 @@ SWIG_Python_AddErrorMsg(const char* mesg)
|
|||
|
||||
if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
|
||||
if (value) {
|
||||
char *tmp;
|
||||
PyObject *old_str = PyObject_Str(value);
|
||||
PyErr_Clear();
|
||||
Py_XINCREF(type);
|
||||
|
||||
PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg);
|
||||
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
|
||||
SWIG_Python_str_DelForPy3(tmp);
|
||||
Py_DECREF(old_str);
|
||||
Py_DECREF(value);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue