ldap/servers/plugins/dna/dna.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 9229db23f5491bf8320967387e88903334dfed94
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Aug 1 18:08:29 2012 -0400
Ticket 407 - memory leak in dna plugin
Bug Description: Valgrind reported a memory leak in dna_pre_op()
Fix Description: Moved the slapi mod allocation, and freed the mods on error.
https://fedorahosted.org/389/ticket/407
Reviewed by: ?
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index ce2486e..70d9c6b 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -3247,12 +3247,8 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
"dna_pre_op: no pre op entry set for modify\n");
goto bail;
}
- /* grab the mods - we'll put them back later with
- * our modifications appended
- */
+ /* grab the mods - we'll put them back later with our modifications appended
*/
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
- smods = slapi_mods_new();
- slapi_mods_init_passin(smods, mods);
/* We need the resulting entry after the mods are applied to
* see if the entry is within the scope. */
@@ -3263,6 +3259,8 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
* to let the main server handle it. */
goto bail;
}
+ smods = slapi_mods_new();
+ slapi_mods_init_passin(&smods, mods);
}
/* For a MOD, we need to check the resulting entry */
@@ -3292,7 +3290,9 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
if (LDAP_CHANGETYPE_ADD == modtype) {
ret = _dna_pre_op_add(pb, test_e);
} else {
- ret = _dna_pre_op_modify(pb, test_e, smods);
+ if((ret = _dna_pre_op_modify(pb, test_e, smods))){
+ slapi_mods_free(&smods);
+ }
}
if (ret) {
goto bail;