summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-20 15:50:58 +1000
committerAndrew Tridgell <tridge@samba.org>2008-08-20 15:50:58 +1000
commitf96f623854d3cd8bdaacd25979618f1cb53b8f93 (patch)
tree6cac92c2fdcc518a02d83cf1d44b5847113e398f /source4/lib/ldb/common
parent7e1c62f8b64c9e42018bea33557af31fb7fa7414 (diff)
parentb33f4541f6157163f9b22af8607ecefe3953638f (diff)
downloadsamba-f96f623854d3cd8bdaacd25979618f1cb53b8f93.tar.gz
samba-f96f623854d3cd8bdaacd25979618f1cb53b8f93.tar.bz2
samba-f96f623854d3cd8bdaacd25979618f1cb53b8f93.zip
Merge commit 'origin/v4-0-test' into v4-0-test
(This used to be commit 3bdc906eb63a494f0d8478c13f8330828aa2f725)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_attributes.c14
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 81aab52a08..1e69f412df 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;
}