From: Howard Chu Date: Tue, 13 Jan 2015 20:56:23 +0000 (+0000) Subject: Plug unlikely memleak (coverity) X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e69e0b559633e7ce975ea7a83f883a9cd3432c6;p=openldap Plug unlikely memleak (coverity) --- diff --git a/libraries/librewrite/subst.c b/libraries/librewrite/subst.c index 95c509353d..4694836fed 100644 --- a/libraries/librewrite/subst.c +++ b/libraries/librewrite/subst.c @@ -194,7 +194,6 @@ rewrite_subst_compile( subs[ nsub ].bv_len = l; subs[ nsub ].bv_val = malloc( l + 1 ); if ( subs[ nsub ].bv_val == NULL ) { - free( subs ); goto cleanup; } AC_MEMCPY( subs[ nsub ].bv_val, begin, l ); @@ -210,11 +209,25 @@ rewrite_subst_compile( } s->lt_subs_len = subs_len; - s->lt_subs = subs; - s->lt_num_submatch = nsub; - s->lt_submatch = submatch; + s->lt_subs = subs; + s->lt_num_submatch = nsub; + s->lt_submatch = submatch; + subs = NULL; + submatch = NULL; cleanup:; + if ( subs ) { + for ( l=0; l