]> git.sur5r.net Git - openldap/blobdiff - libraries/librewrite/info.c
Merge remote branch 'origin/mdb.master'
[openldap] / libraries / librewrite / info.c
index faa2424c3fd92935961dcd93bbffb5e26143ac84..7ff1e45441a9a49c3f223df68f2957e93bcefea3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Copyright 2000-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -81,10 +81,13 @@ rewrite_info_init(
 
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
        if ( ldap_pvt_thread_rdwr_init( &info->li_cookies_mutex ) ) {
+               avl_free( info->li_context, rewrite_context_free );
                free( info );
                return NULL;
        }
        if ( ldap_pvt_thread_rdwr_init( &info->li_params_mutex ) ) {
+               ldap_pvt_thread_rdwr_destroy( &info->li_cookies_mutex );
+               avl_free( info->li_context, rewrite_context_free );
                free( info );
                return NULL;
        }
@@ -116,7 +119,7 @@ rewrite_info_delete(
        if ( info->li_maps ) {
                avl_free( info->li_maps, rewrite_builtin_map_free );
        }
-       info->li_context = NULL;
+       info->li_maps = NULL;
 
        rewrite_session_destroy( info );
 
@@ -213,7 +216,7 @@ rewrite_session(
 
                case REWRITE_MODE_COPY_INPUT:
                        *result = strdup( string );
-                       rc = REWRITE_REGEXEC_OK;
+                       rc = ( *result != NULL ) ? REWRITE_REGEXEC_OK : REWRITE_REGEXEC_ERR;
                        goto rc_return;
 
                case REWRITE_MODE_USE_DEFAULT:
@@ -261,7 +264,9 @@ rewrite_session(
        case REWRITE_REGEXEC_UNWILLING:
        case REWRITE_REGEXEC_ERR:
                if ( *result != NULL ) {
-                       free( *result );
+                       if ( *result != string ) {
+                               free( *result );
+                       }
                        *result = NULL;
                }