diff options
Diffstat (limited to 'Examples/python/multimap/example.i')
-rw-r--r-- | Examples/python/multimap/example.i | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 3ff5d52c0..7087d426b 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -39,12 +39,14 @@ extern int gcd(int x, int y); %#if PY_VERSION_HEX >= 0x03000000 { PyObject *utf8str = PyUnicode_AsUTF8String(s); - const char *cstr; + const char *strtmp = 0; if (!utf8str) { SWIG_fail; } - cstr = PyBytes_AsString(utf8str); - $2[i] = strdup(cstr); + strtmp = PyBytes_AsString(utf8str); + $2[i] = (char *)malloc(strlen(strtmp) + 1); + if ($2[i]) + strcpy($2[i], strtmp); Py_DECREF(utf8str); } %#else |