]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/search.c
Import minor trace output cleanup
[openldap] / servers / slapd / back-ldbm / search.c
index 959411b2359eca66ec18f429ce543097b27b22cd..438397f441d8dfb5dd3095036c39c350842bdd02 100644 (file)
@@ -49,7 +49,7 @@ ldbm_back_search(
        ID              id;
        Entry           *e;
        Attribute       *ref;
-       char            *matched;
+       char            *matched = NULL;
        int             rmaxsize, nrefs;
        char            *rbuf, *rcur, *r;
        int             nentries = 0;
@@ -79,7 +79,6 @@ ldbm_back_search(
        switch ( deref ) {
        case LDAP_DEREF_FINDING:
        case LDAP_DEREF_ALWAYS:
-               free (realBase);
                realBase = derefDN ( be, conn, op, base );
                break;
        default:
@@ -88,7 +87,7 @@ ldbm_back_search(
 
        (void) dn_normalize (realBase);
 
-       Debug( LDAP_DEBUG_TRACE, "using base %s\n",
+       Debug( LDAP_DEBUG_TRACE, "using base \"%s\"\n",
                realBase, 0, 0 );
 
        switch ( scope ) {
@@ -110,6 +109,9 @@ ldbm_back_search(
        default:
                send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, "",
                    "Bad scope" );
+               if( realBase != NULL) {
+                       free( realBase );
+               }
                return( -1 );
        }
 
@@ -119,9 +121,16 @@ ldbm_back_search(
                if ( matched != NULL ) {
                        free( matched );
                }
+               if( realBase != NULL) {
+                       free( realBase );
+               }
                return( -1 );
        }
 
+       if ( matched != NULL ) {
+               free( matched );
+       }
+
        rmaxsize = 0;
        nrefs = 0;
        rbuf = rcur = NULL;
@@ -136,6 +145,9 @@ ldbm_back_search(
                        pthread_mutex_unlock( &op->o_abandonmutex );
                        idl_free( candidates );
                        free( rbuf );
+                       if( realBase != NULL) {
+                               free( realBase );
+                       }
                        return( 0 );
                }
                pthread_mutex_unlock( &op->o_abandonmutex );
@@ -150,6 +162,9 @@ ldbm_back_search(
                            NULL, nentries );
                        idl_free( candidates );
                        free( rbuf );
+                       if( realBase != NULL) {
+                               free( realBase );
+                       }
                        return( 0 );
                }
                pthread_mutex_unlock( &currenttime_mutex );
@@ -222,6 +237,10 @@ ldbm_back_search(
                                                        nrefs > 0 ? rbuf : NULL, nentries );
                                                idl_free( candidates );
                                                free( rbuf );
+
+                                               if( realBase != NULL) {
+                                                       free( realBase );
+                                               }
                                                return( 0 );
                                        }
 
@@ -251,6 +270,10 @@ ldbm_back_search(
                                                cache_return_entry_r( &li->li_cache, e );
                                                idl_free( candidates );
                                                free( rbuf );
+
+                                               if( realBase != NULL) {
+                                                       free( realBase );
+                                               }
                                                return( 0 );
                                        }
                                }
@@ -274,6 +297,10 @@ ldbm_back_search(
        }
        free( rbuf );
 
+       if( realBase != NULL) {
+               free( realBase );
+       }
+
        return( 0 );
 }
 
@@ -296,7 +323,7 @@ base_candidates(
        IDList          *idl;
        Entry           *e;
 
-       Debug(LDAP_DEBUG_TRACE, "base_candidates: base: %s\n", base, 0, 0);
+       Debug(LDAP_DEBUG_TRACE, "base_candidates: base: \"%s\"\n", base, 0, 0);
 
        *err = LDAP_SUCCESS;
 
@@ -337,7 +364,7 @@ onelevel_candidates(
        char            buf[20];
        IDList          *candidates;
 
-       Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: %s\n", base, 0, 0);
+       Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: \"%s\"\n", base, 0, 0);
 
        *err = LDAP_SUCCESS;
        e = NULL;
@@ -395,11 +422,11 @@ subtree_candidates(
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       Filter          *f;
+       Filter          *f, **filterarg_ptr;
        IDList          *candidates;
 
-       Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: %s\n",
-               base ? base : "NULL", 0, 0);
+       Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" %s\n",
+               base ? base : "NULL", lookupbase ? "lookupbase" : "", 0);
 
        /*
         * get the base object - unless we already have it (from one-level).
@@ -435,7 +462,8 @@ subtree_candidates(
                /* Patch to use normalized uppercase */
                f->f_or->f_avvalue.bv_val = ch_strdup( "REFERRAL" );
                f->f_or->f_avvalue.bv_len = strlen( "REFERRAL" );
-               f->f_or->f_next = filter;
+               filterarg_ptr = &f->f_or->f_next;
+               *filterarg_ptr = filter;
                filter = f;
 
                if ( ! be_issuffix( be, base ) ) {
@@ -458,7 +486,7 @@ subtree_candidates(
 
        /* free up just the parts we allocated above */
        if ( f != NULL ) {
-               f->f_and->f_next = NULL;
+               *filterarg_ptr = NULL;
                filter_free( f );
        }