Fix possible refleaks.
diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
index da8207a..9a55d76 100644
--- a/Lib/python/pyhead.swg
+++ b/Lib/python/pyhead.swg
@@ -43,12 +43,11 @@
   if (str) {
     char *cstr;
     Py_ssize_t len;
-    if (PyBytes_AsStringAndSize(str, &cstr, &len) == -1)
-      return NULL;
-    newstr = (char *) malloc(len+1);
-    if (!newstr)
-      return NULL;
-    memcpy(newstr, cstr, len+1);
+    if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) {
+      newstr = (char *) malloc(len+1);
+      if (newstr)
+        memcpy(newstr, cstr, len+1);
+    }
     Py_XDECREF(str);
   }
   return newstr;