diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-08-19 14:11:51 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-08-19 14:11:51 +1000 |
commit | b33f4541f6157163f9b22af8607ecefe3953638f (patch) | |
tree | cb36a27033500dff5790789e696a4d24bf8ec30f /source4/lib/ldb/common/ldb_attributes.c | |
parent | 7ef21658fbb519859aa7d23a614e1fdbcae95693 (diff) | |
parent | aef684da3149eaf2b8d87c4903af241c9a2311a6 (diff) | |
download | samba-b33f4541f6157163f9b22af8607ecefe3953638f.tar.gz samba-b33f4541f6157163f9b22af8607ecefe3953638f.tar.bz2 samba-b33f4541f6157163f9b22af8607ecefe3953638f.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
(This used to be commit fc6b4f03ebba015a13a6ab93221b0bc3ef8ef2ed)
Diffstat (limited to 'source4/lib/ldb/common/ldb_attributes.c')
-rw-r--r-- | source4/lib/ldb/common/ldb_attributes.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index effd93ae26..ab6aa0b734 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -62,11 +62,20 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, ldb->schema.attributes = a; for (i = 0; i < ldb->schema.num_attributes; i++) { - if (ldb_attr_cmp(attribute, a[i].name) < 0) { + int cmp = ldb_attr_cmp(attribute, a[i].name); + if (cmp == 0) { + if (a[i].flags & LDB_ATTR_FLAG_ALLOCATED) { + talloc_free(discard_const_p(char, a[i].name)); + } + /* To cancel out increment below */ + ldb->schema.num_attributes--; + break; + } else if (cmp < 0) { memmove(a+i+1, a+i, sizeof(*a) * (ldb->schema.num_attributes-i)); break; } } + ldb->schema.num_attributes++; a[i].name = attribute; a[i].flags = flags; @@ -80,7 +89,6 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, } } - ldb->schema.num_attributes++; return 0; } @@ -145,7 +153,7 @@ void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name) int i; a = ldb_schema_attribute_by_name(ldb, name); - if (a == NULL) { + if (a == NULL || a->name == NULL) { return; } |