From a9067fc056422f91a9bea1efb8afa8058306d2b3 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 4 Nov 2005 01:29:48 +0000 Subject: [PATCH] free values in case of error --- servers/slapd/add.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 250da6093a..eb0af1569b 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -46,7 +46,7 @@ do_add( Operation *op, SlapReply *rs ) Modifications tmp; char textbuf[ SLAP_TEXT_BUFLEN ]; size_t textlen = sizeof( textbuf ); - int rc = 0; + int rc = 1; Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 ); /* @@ -194,7 +194,14 @@ do_add( Operation *op, SlapReply *rs ) done:; if ( modlist != NULL ) { - slap_mods_free( modlist, 0 ); + int freevals = 0; + + if ( rc != 0 && op->ora_e == NULL ) { + freevals = 1; + } + + /* in case of error, free the values as well */ + slap_mods_free( modlist, freevals ); } if ( op->ora_e != NULL ) {