From: Andrew Bartlett Date: Mon, 4 Jul 2016 02:06:10 +0000 (+1200) Subject: schema: Reorder dsdb_set_schema() to unlink the old schema last X-Git-Tag: tdb-1.3.10~475 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51d2779a60b0b5d358e0b3473324ce4b606d52b7;p=thirdparty%2Fsamba.git schema: Reorder dsdb_set_schema() to unlink the old schema last Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 6029e46a7a1..1b29c4dce4b 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -475,32 +475,33 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema) old_schema = ldb_get_opaque(ldb, "dsdb_schema"); - ret = ldb_set_opaque(ldb, "dsdb_schema", schema); + ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL); if (ret != LDB_SUCCESS) { return ret; } - /* Remove the reference to the schema we just overwrote - if there was - * none, NULL is harmless here */ - if (old_schema != schema) { - talloc_unlink(ldb, old_schema); - talloc_steal(ldb, schema); - } - - talloc_steal(ldb, schema); - - ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL); + ret = ldb_set_opaque(ldb, "dsdb_schema", schema); if (ret != LDB_SUCCESS) { return ret; } + talloc_steal(ldb, schema); + /* Set the new attributes based on the new schema */ ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true); if (ret != LDB_SUCCESS) { return ret; } - return LDB_SUCCESS; + /* + * Remove the reference to the schema we just overwrote - if there was + * none, NULL is harmless here. + */ + if (old_schema != schema) { + talloc_unlink(ldb, old_schema); + } + + return ret; } /**