X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibrewrite%2Fsubst.c;h=8efed1422090277d06a2b4428ec6d51e59c39088;hb=3e2cf8cae7bec60d0430328c06e8002b2c17572b;hp=95c509353d06616181e54cff5ec3dadfefed6643;hpb=d800cd71fe67bb5ee9e10867db2442da30f0d9d7;p=openldap
diff --git a/libraries/librewrite/subst.c b/libraries/librewrite/subst.c
index 95c509353d..8efed14220 100644
--- a/libraries/librewrite/subst.c
+++ b/libraries/librewrite/subst.c
@@ -1,7 +1,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2000-2014 The OpenLDAP Foundation.
+ * Copyright 2000-2017 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -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