Skip to content

Commit 58e409d

Browse files
committed
Fix possible refleaks.
1 parent 6adf19b commit 58e409d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Lib/python/pyhead.swg

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ SWIG_Python_str_AsChar(PyObject *str)
4343
if (str) {
4444
char *cstr;
4545
Py_ssize_t len;
46-
if (PyBytes_AsStringAndSize(str, &cstr, &len) == -1)
47-
return NULL;
48-
newstr = (char *) malloc(len+1);
49-
if (!newstr)
50-
return NULL;
51-
memcpy(newstr, cstr, len+1);
46+
if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) {
47+
newstr = (char *) malloc(len+1);
48+
if (newstr)
49+
memcpy(newstr, cstr, len+1);
50+
}
5251
Py_XDECREF(str);
5352
}
5453
return newstr;

0 commit comments

Comments
 (0)