Applied memory leak patch.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9b62acf02c
commit
5f5f2213af
1 changed files with 15 additions and 3 deletions
|
|
@ -294,18 +294,29 @@ SWIG_ConvertPtr(PyObject *obj, void **ptr, _swig_type_info *ty, int flags) {
|
|||
if (!SWIG_this)
|
||||
SWIG_this = PyString_InternFromString("this");
|
||||
obj = PyObject_GetAttr(obj,SWIG_this);
|
||||
if ((!obj) || !(PyString_Check(obj))) goto type_error;
|
||||
newref = 1;
|
||||
if (!obj) goto type_error;
|
||||
if (!PyString_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c = PyString_AsString(obj);
|
||||
p = 0;
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) return 0;
|
||||
if (strcmp(c,"NULL") == 0) {
|
||||
if (newref) Py_DECREF(obj);
|
||||
return 0;
|
||||
} else {
|
||||
if (newref) Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c++;
|
||||
/* Extract hex value from pointer */
|
||||
while (d = *c) {
|
||||
while ((d = *c)) {
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
p = (p << 4) + (d - '0');
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
|
|
@ -315,6 +326,7 @@ SWIG_ConvertPtr(PyObject *obj, void **ptr, _swig_type_info *ty, int flags) {
|
|||
c++;
|
||||
}
|
||||
*ptr = (void *) p;
|
||||
if (newref) Py_DECREF(obj);
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue