diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-10-01 13:59:02 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-10-01 13:59:02 +0200 |
commit | 54ea150f364f9c39a9f0a2abe5a98e82df62845a (patch) | |
tree | 8a51f26bcb4ae8f835abf8b0777945a1e94f6f35 /source4/lib/ldb/common/ldb_msg.c | |
parent | e80891db4123a2ae326517c27c559ace18b0f05b (diff) | |
download | samba-54ea150f364f9c39a9f0a2abe5a98e82df62845a.tar.gz samba-54ea150f364f9c39a9f0a2abe5a98e82df62845a.tar.bz2 samba-54ea150f364f9c39a9f0a2abe5a98e82df62845a.zip |
s4:ldb_msg_diff - Fixes up possible memory leaks and the python binding of it
Diffstat (limited to 'source4/lib/ldb/common/ldb_msg.c')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 702978a361..929f24cd88 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -560,6 +560,9 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, unsigned int i; mod = ldb_msg_new(ldb); + if (mod == NULL) { + return NULL; + } mod->dn = msg1->dn; mod->num_elements = 0; @@ -567,6 +570,7 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, msg2 = ldb_msg_canonicalize(ldb, msg2); if (msg2 == NULL) { + talloc_free(mod); return NULL; } @@ -581,7 +585,8 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, if (ldb_msg_add(mod, &msg2->elements[i], - el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != 0) { + el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != LDB_SUCCESS) { + talloc_free(mod); return NULL; } } @@ -589,10 +594,11 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, /* look in msg1 to find elements that need to be deleted */ for (i=0;i<msg1->num_elements;i++) { el = ldb_msg_find_element(msg2, msg1->elements[i].name); - if (!el) { + if (el == NULL) { if (ldb_msg_add_empty(mod, msg1->elements[i].name, - LDB_FLAG_MOD_DELETE, NULL) != 0) { + LDB_FLAG_MOD_DELETE, NULL) != LDB_SUCCESS) { + talloc_free(mod); return NULL; } } |