map = rewrite_xmap_parse( info,
p + 3, (const char **)&begin );
if ( map == NULL ) {
+ nsub++; /* make sure subs[nsub] is freed */
goto cleanup;
}
submatch[ nsub ].ls_map = map;
map = rewrite_map_parse( info, p + 2,
(const char **)&begin );
if ( map == NULL ) {
+ nsub++; /* make sure subs[nsub] is freed */
goto cleanup;
}
p = begin - 1;
continue;
} else {
+ nsub++; /* make sure subs[nsub] is freed */
goto cleanup;
}
*/
tmps = (struct berval * )realloc( subs, sizeof( struct berval )*( nsub + 1 ) );
if ( tmps == NULL ) {
- /*
- * XXX need to free the value subst stuff!
- */
- free( subs );
goto cleanup;
}
subs = tmps;
s = calloc( sizeof( struct rewrite_subst ), 1 );
if ( s == NULL ) {
+ nsub++; /* make sure last elements are freed */
goto cleanup;
}
cleanup:;
if ( subs ) {
for ( l=0; l<nsub; l++ ) {
- free( subs[nsub].bv_val );
+ free( subs[l].bv_val );
}
free( subs );
}
if ( submatch ) {
for ( l=0; l<nsub; l++ ) {
- free( submatch[nsub].ls_map );
+ free( submatch[l].ls_map );
}
free( submatch );
}