Try to avoid a memory leak if we re-set the global schema
authorAndrew Bartlett <abartlet@samba.org>
Fri, 25 Jul 2008 01:58:24 +0000 (11:58 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 25 Jul 2008 01:58:24 +0000 (11:58 +1000)
However, try also not to pull a schema out from under a running ldb
session.

Andrew Bartlett
(This used to be commit 7cf9b9dd0bb35835a7c6e9897ea99951a33c63c7)

source4/dsdb/schema/schema_init.c

index 71d952b944bbaa926fd4aaab9fccb3a89246cc8c..75457b4bea0be909cf374767e198bde8f1ff8ec4 100644 (file)
@@ -1534,6 +1534,11 @@ int dsdb_set_global_schema(struct ldb_context *ldb)
                return ret;
        }
 
+       /* Keep a reference to this schema, just incase the global copy is replaced */
+       if (talloc_reference(ldb, global_schema) == NULL) {
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
        return LDB_SUCCESS;
 }
 
@@ -1571,6 +1576,10 @@ void dsdb_make_schema_global(struct ldb_context *ldb)
                return;
        }
 
+       if (global_schema) {
+               talloc_unlink(talloc_autofree_context(), schema);
+       }
+
        talloc_steal(talloc_autofree_context(), schema);
        global_schema = schema;