Fix possible refleaks.
This commit is contained in:
parent
6adf19b52f
commit
58e409dd2b
1 changed files with 5 additions and 6 deletions
|
|
@ -43,12 +43,11 @@ SWIG_Python_str_AsChar(PyObject *str)
|
||||||
if (str) {
|
if (str) {
|
||||||
char *cstr;
|
char *cstr;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
if (PyBytes_AsStringAndSize(str, &cstr, &len) == -1)
|
if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) {
|
||||||
return NULL;
|
newstr = (char *) malloc(len+1);
|
||||||
newstr = (char *) malloc(len+1);
|
if (newstr)
|
||||||
if (!newstr)
|
memcpy(newstr, cstr, len+1);
|
||||||
return NULL;
|
}
|
||||||
memcpy(newstr, cstr, len+1);
|
|
||||||
Py_XDECREF(str);
|
Py_XDECREF(str);
|
||||||
}
|
}
|
||||||
return newstr;
|
return newstr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue