)
{
size_t subs_len;
- struct berval **subs = NULL;
+ struct berval **subs = NULL, **tmps;
struct rewrite_submatch **submatch = NULL;
struct rewrite_subst *s = NULL;
nsub++;
- subs = (struct berval **)realloc( subs,
+ tmps = (struct berval **)realloc( subs,
sizeof( struct berval * )*( nsub + 1 ) );
- if ( subs == NULL ) {
+ if ( tmps == NULL ) {
/* cleanup */
return NULL;
}
+ subs = tmps;
subs[ nsub ] = NULL;
/*
*/
if ( isdigit( p[ 1 ] ) ) {
int d = p[ 1 ] - '0';
+ struct rewrite_submatch **tmpsm;
/*
* Add a new value substitution scheme
*/
- submatch = realloc( submatch,
+ tmpsm = realloc( submatch,
sizeof( struct rewrite_submatch * )*( nsub + 1 ) );
- if ( submatch == NULL ) {
+ if ( tmpsm == NULL ) {
/* cleanup */
return NULL;
}
+ submatch = tmpsm;
submatch[ nsub ] = NULL;
+
submatch[ nsub - 1 ] =
calloc( sizeof( struct rewrite_submatch ), 1 );
if ( submatch[ nsub - 1 ] == NULL ) {
*/
} else if ( p[ 1 ] == '{' ) {
struct rewrite_map *map;
+ struct rewrite_submatch **tmpsm;
map = rewrite_map_parse( info, p + 2, &begin );
if ( map == NULL ) {
/*
* Add a new value substitution scheme
*/
- submatch = realloc( submatch,
+ tmpsm = realloc( submatch,
sizeof( struct rewrite_submatch * )*( nsub + 1 ) );
- if ( submatch == NULL ) {
+ if ( tmpsm == NULL ) {
/* cleanup */
return NULL;
}
+ submatch = tmpsm;
submatch[ nsub ] = NULL;
submatch[ nsub - 1 ] =
calloc( sizeof( struct rewrite_submatch ), 1 );
/*
* Last part of string
*/
- subs = realloc( subs, sizeof( struct berval *)*( nsub + 2 ) );
- if ( subs == NULL ) {
+ tmps = realloc( subs, sizeof( struct berval *)*( nsub + 2 ) );
+ if ( tmps == NULL ) {
/*
* XXX need to free the value subst stuff!
*/
free( submatch );
return NULL;
}
-
+
+ subs = tmps;
subs[ nsub + 1 ] = NULL;
l = p - begin;
if ( l > 0 ) {