{
const char *s1 = NULL;
const char *s2 = NULL;
-
+ long cmp_result = 0;
if (!PyArg_ParseTuple(args, "eses", "utf8", &s1, "utf8", &s2)) {
return NULL;
}
- return PyInt_FromLong(strcasecmp_m(s1, s2));
+ cmp_result = strcasecmp_m(s1, s2);
+ PyMem_Free(discard_const_p(char, s1));
+ PyMem_Free(discard_const_p(char, s2));
+ return PyInt_FromLong(cmp_result);
}
static PyObject *py_strstr_m(PyObject *self, PyObject *args)
{
const char *s1 = NULL;
const char *s2 = NULL;
- char *ret = NULL;
-
+ char *strstr_ret = NULL;
+ PyObject *result = NULL;
if (!PyArg_ParseTuple(args, "eses", "utf8", &s1, "utf8", &s2))
return NULL;
- ret = strstr_m(s1, s2);
- if (!ret) {
+ strstr_ret = strstr_m(s1, s2);
+ if (!strstr_ret) {
+ PyMem_Free(discard_const_p(char, s1));
+ PyMem_Free(discard_const_p(char, s2));
Py_RETURN_NONE;
}
- return PyUnicode_FromString(ret);
+ result = PyUnicode_FromString(strstr_ret);
+ PyMem_Free(discard_const_p(char, s1));
+ PyMem_Free(discard_const_p(char, s2));
+ return result;
}
static PyMethodDef py_misc_methods[] = {