summaryrefslogtreecommitdiff
path: root/libgpo/pygpo.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-08-17 10:11:03 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-17 11:30:10 +0200
commit0f6b4b43711522f4770fb256f328b4b1a3893ffc (patch)
tree4a161391cd93b14f40306f5893722c47a3073a8e /libgpo/pygpo.c
parent682fafe2b3a7b196975897d6e162392d64bec4d1 (diff)
downloadsamba-0f6b4b43711522f4770fb256f328b4b1a3893ffc.tar.gz
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>
Diffstat (limited to 'libgpo/pygpo.c')
-rw-r--r--libgpo/pygpo.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c
index 60220a6bc2a..88486424917 100644
--- a/libgpo/pygpo.c
+++ b/libgpo/pygpo.c
@@ -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;
}