s4:ldb Fix talloc hirarchy in LDIF parsing code
authorAndrew Bartlett <abartlet@samba.org>
Sun, 5 Jul 2009 23:24:18 +0000 (09:24 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 5 Jul 2009 23:50:47 +0000 (09:50 +1000)
The problem here was that some parts of the ldb_message were still
attached to the ldb_ldif structure, and when only the message was
taken (and the ldif free'ed to reclaim memory) we refereced free'ed
memory.

Andrew Bartlett

source4/lib/ldb/common/ldb_ldif.c

index 400fb352ff4aba05ef06d976f4034b81cf8e9a10..d64a9f1c3a813e07c584c854a99fc19b0cc4d50e 100644 (file)
@@ -632,7 +632,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
                        if (!el->values) {
                                goto failed;
                        }
                        if (!el->values) {
                                goto failed;
                        }
-                       ret = a->syntax->ldif_read_fn(ldb, ldif, &value, &el->values[el->num_values]);
+                       ret = a->syntax->ldif_read_fn(ldb, el->values, &value, &el->values[el->num_values]);
                        if (ret != 0) {
                                goto failed;
                        }
                        if (ret != 0) {
                                goto failed;
                        }
@@ -647,7 +647,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
                        el->num_values++;
                } else {
                        /* its a new attribute */
                        el->num_values++;
                } else {
                        /* its a new attribute */
-                       msg->elements = talloc_realloc(ldif, msg->elements, 
+                       msg->elements = talloc_realloc(msg, msg->elements, 
                                                         struct ldb_message_element, 
                                                         msg->num_elements+1);
                        if (!msg->elements) {
                                                         struct ldb_message_element, 
                                                         msg->num_elements+1);
                        if (!msg->elements) {
@@ -661,7 +661,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
                                goto failed;
                        }
                        el->num_values = 1;
                                goto failed;
                        }
                        el->num_values = 1;
-                       ret = a->syntax->ldif_read_fn(ldb, ldif, &value, &el->values[0]);
+                       ret = a->syntax->ldif_read_fn(ldb, el->values, &value, &el->values[0]);
                        if (ret != 0) {
                                goto failed;
                        }
                        if (ret != 0) {
                                goto failed;
                        }