mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
python: Fix memory leak with ParseTuple (using 'es' format)
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
e61f9406de
commit
5232979de8
@ -300,28 +300,36 @@ static PyObject *py_strcasecmp_m(PyObject *self, PyObject *args)
|
||||
{
|
||||
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[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user