ldb: Don’t decrement reference count until object is no longer needed
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 31 Jul 2023 21:56:49 +0000 (09:56 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 8 Aug 2023 04:39:37 +0000 (04:39 +0000)
If ‘tmp’ happens to be garbage-collected, ‘name’ will become invalid.

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

index 6215efb3d4da8285ac1d8931102fca4c77558e37..8db6ccb8bc10f05fcd99dbb78ce5a803756f63b3 100644 (file)
@@ -4363,10 +4363,10 @@ static PyObject *py_register_module(PyObject *module, PyObject *args)
                TALLOC_FREE(ops);
                return NULL;
        }
-       Py_XDECREF(tmp);
        Py_INCREF(input);
 
        ops->name = talloc_strdup(ops, name);
+       Py_XDECREF(tmp);
        ops->private_data = input;
        ops->init_context = py_module_init;
        ops->search = py_module_search;