]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backglue.c
make sure NULL pointers are not dereferenced
[openldap] / servers / slapd / backglue.c
index d60542d12fcaa95ead9178824c1978842ed30827..f9b3cdce071fa54963baefb7e15ffeb667bfa161 100644 (file)
@@ -269,12 +269,14 @@ glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0,
        /* Process any overlays on the master backend */
        if ( op->o_bd == b0 && on->on_next ) {
                BackendInfo *bi = op->o_bd->bd_info;
-               int rc;
+               int rc = SLAP_CB_CONTINUE;
                for ( on=on->on_next; on; on=on->on_next ) {
                        op->o_bd->bd_info = (BackendInfo *)on;
-                       rc = on->on_bi.bi_op_search( op, rs );
-                       if ( rc != SLAP_CB_CONTINUE )
-                               break;
+                       if ( on->on_bi.bi_op_search ) {
+                               rc = on->on_bi.bi_op_search( op, rs );
+                               if ( rc != SLAP_CB_CONTINUE )
+                                       break;
+                       }
                }
                op->o_bd->bd_info = bi;
                if ( rc != SLAP_CB_CONTINUE )
@@ -441,7 +443,7 @@ end_of_loop:;
        if (gs.refs)
                ber_bvarray_free(gs.refs);
        if (gs.ctrls) {
-               for (gs.nctrls-1; i>=0; i--) {
+               for (i = gs.nctrls; --i >= 0; ) {
                        if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value ))
                                free(gs.ctrls[i]->ldctl_value.bv_val);
                        free(gs.ctrls[i]);