Skip to content
Snippets Groups Projects
Commit f5c0af56 authored by Howard Chu's avatar Howard Chu
Browse files

Plug unlikely memleak (coverity)

parent 7c65afc2
No related branches found
No related tags found
No related merge requests found
......@@ -155,6 +155,7 @@ rewrite_subst_compile(
tmpsm = ( struct rewrite_submatch * )realloc( submatch,
sizeof( struct rewrite_submatch )*( nsub + 1 ) );
if ( tmpsm == NULL ) {
rewrite_map_destroy( &map );
goto cleanup;
}
submatch = tmpsm;
......@@ -194,7 +195,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 +210,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<nsub; l++ ) {
free( subs[nsub].bv_val );
}
free( subs );
}
if ( submatch ) {
for ( l=0; l<nsub; l++ ) {
free( submatch[nsub].ls_map );
}
free( submatch );
}
free( result );
return s;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment