s3:param: Use a talloc stackframe in pyparam
[samba.git] / source3 / param / pyparam.c
index 749cfe308f4d845da7ea7ee9a2531010d22b746e..6559661901dfb856b0419b13a350c1b15cc0c586 100644 (file)
@@ -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;
 }