lib/ldb: Allocate opaque on ldb_ctx
authorAndrew Bartlett <abartlet@samba.org>
Mon, 4 Mar 2024 00:02:54 +0000 (13:02 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 5 Mar 2024 02:54:36 +0000 (02:54 +0000)
Just in case this LDB is given away into the C code, that opaque must live
as long as the LDB itself, not the python wrapper object.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
lib/ldb/pyldb.c

index 435f2477672d8484005e28f5dc4ce969bcfb3579..5d995243d4462457f4aa9ff5e986df253b6abff3 100644 (file)
@@ -2475,7 +2475,7 @@ static PyObject *py_ldb_set_opaque(PyLdbObject *self, PyObject *args)
                        b = is_true;
                }
 
-               opaque = talloc(self->mem_ctx, bool);
+               opaque = talloc(self->ldb_ctx, bool);
                if (opaque == NULL) {
                        return PyErr_NoMemory();
                }
@@ -2488,7 +2488,7 @@ static PyObject *py_ldb_set_opaque(PyLdbObject *self, PyObject *args)
                        return NULL;
                }
 
-               opaque = talloc(self->mem_ctx, unsigned long long);
+               opaque = talloc(self->ldb_ctx, unsigned long long);
                if (opaque == NULL) {
                        return PyErr_NoMemory();
                }
@@ -2501,7 +2501,7 @@ static PyObject *py_ldb_set_opaque(PyLdbObject *self, PyObject *args)
                        return NULL;
                }
 
-               opaque = talloc_strdup(self->mem_ctx, s);
+               opaque = talloc_strdup(self->ldb_ctx, s);
                if (opaque == NULL) {
                        return PyErr_NoMemory();
                }