mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
pygpo: Fix a talloc_tos() leak in py_gpo_get_unix_path
cache_path() implicitly puts its result on talloc_tos(). As in py_gpo_get_unix_path the talloc_stackframe() is only created after the cache_path() call, we leak the result of cache_path() on talloc_tos() (which might or might not exist). This converts the function to the pattern used elsewhere: Create the stackframe as the very first action and remove it as the very last action in the function. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
682fafe2b3
commit
0f6b4b4371
@ -81,6 +81,8 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
|
||||
struct GROUP_POLICY_OBJECT *gpo_ptr \
|
||||
= (struct GROUP_POLICY_OBJECT *)pytalloc_get_ptr(self);
|
||||
|
||||
frame = talloc_stackframe();
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s",
|
||||
discard_const_p(char *, kwlist),
|
||||
&cache_dir)) {
|
||||
@ -99,12 +101,8 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
|
||||
}
|
||||
}
|
||||
|
||||
frame = talloc_stackframe();
|
||||
|
||||
status = gpo_get_unix_path(frame, cache_dir, gpo_ptr, &unix_path);
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"Failed to determine gpo unix path");
|
||||
@ -114,6 +112,7 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
|
||||
ret = PyStr_FromString(unix_path);
|
||||
|
||||
out:
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user