From 49424f18b193ad3ac17f4bee8cc866213d8481d6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 25 Oct 2023 12:26:44 +0200 Subject: [PATCH] s3:param: Use a talloc stackframe in pyparam Several parts of the code use talloc_tos() requiring a stackframe to be present. This is needed as loadparm_init_s3() will call init_globals() later. Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source3/param/pyparam.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/source3/param/pyparam.c b/source3/param/pyparam.c index 749cfe308f4..6559661901d 100644 --- a/source3/param/pyparam.c +++ b/source3/param/pyparam.c @@ -33,30 +33,25 @@ static PyObject *py_get_context(PyObject *self, PyObject *Py_UNUSED(ignored)) PyObject *py_loadparm; const struct loadparm_s3_helpers *s3_context; const struct loadparm_context *s4_context; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_new(NULL); - if (mem_ctx == NULL) { - PyErr_NoMemory(); - return NULL; - } + TALLOC_CTX *frame = talloc_stackframe(); s3_context = loadparm_s3_helpers(); - s4_context = loadparm_init_s3(mem_ctx, s3_context); + s4_context = loadparm_init_s3(frame, s3_context); if (s4_context == NULL) { + talloc_free(frame); PyErr_NoMemory(); return NULL; } py_loadparm = pytalloc_steal(loadparm_Type, discard_const_p(struct loadparm_context, s4_context)); if (py_loadparm == NULL) { - talloc_free(mem_ctx); + talloc_free(frame); PyErr_NoMemory(); return NULL; } - talloc_free(mem_ctx); + talloc_free(frame); return py_loadparm; } -- 2.47.3