]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/rwmdn.c
Plug memleak when query isn't added to cache
[openldap] / servers / slapd / overlays / rwmdn.c
index 931687b70d9a900c91d678110030ccbf592c7c82..f76487799b4a08cd81f2915a7069d165ab34809d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2005 The OpenLDAP Foundation.
+ * Copyright 1999-2006 The OpenLDAP Foundation.
  * Portions Copyright 1999-2003 Howard Chu.
  * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
@@ -16,7 +16,7 @@
  * <http://www.OpenLDAP.org/license.html>.
  */
 /* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Howard Chu for inclusion
+ * This work was initially developed by Howard Chu for inclusion
  * in OpenLDAP Software and subsequently enhanced by Pierangelo
  * Masarati.
  */
@@ -157,13 +157,14 @@ rwm_dn_massage(
 {
        int             rc = 0;
        struct berval   mdn;
+       static char     *dmy = "";
 
-       assert( dc );
-       assert( in );
-       assert( dn );
+       assert( dc != NULL );
+       assert( in != NULL );
+       assert( dn != NULL );
 
        rc = rewrite_session( dc->rwmap->rwm_rw, dc->ctx,
-                       ( in->bv_len ? in->bv_val : "" ), 
+                       ( in->bv_val ? in->bv_val : dmy ), 
                        dc->conn, &mdn.bv_val );
        switch ( rc ) {
        case REWRITE_REGEXEC_OK:
@@ -197,6 +198,14 @@ rwm_dn_massage(
                break;
        }
 
+       if ( mdn.bv_val == dmy ) {
+               BER_BVZERO( &mdn );
+       }
+
+       if ( dn->bv_val == dmy ) {
+               BER_BVZERO( dn );
+       }
+
        return rc;
 }
 
@@ -216,9 +225,9 @@ rwm_dn_massage(
        int             i, src, dst;
        struct berval   tmpin;
 
-       assert( dc );
-       assert( in );
-       assert( dn );
+       assert( dc != NULL );
+       assert( in != NULL );
+       assert( dn != NULL );
 
        BER_BVZERO( dn );