]> git.sur5r.net Git - openldap/commitdiff
make sure realloc'd memory is reset
authorPierangelo Masarati <ando@openldap.org>
Sat, 13 May 2006 02:06:10 +0000 (02:06 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 13 May 2006 02:06:10 +0000 (02:06 +0000)
servers/slapd/back-meta/conn.c

index 1158d2f00dbd412e070fb04197cbf1d7f3851eb6..75f2261c9d8d46bc9a3ac3d0d92265b70fec110c 100644 (file)
@@ -754,9 +754,11 @@ meta_back_candidates_get( Operation *op )
        } else if ( mc->mc_ntargets < mi->mi_ntargets ) {
                /* NOTE: in the future, may want to allow back-config
                 * to add/remove targets from back-meta... */
-               mc->mc_ntargets = mi->mi_ntargets;
                mc->mc_candidates = ch_realloc( mc->mc_candidates,
-                               sizeof( SlapReply ) * mc->mc_ntargets );
+                               sizeof( SlapReply ) * mi->mi_ntargets );
+               memset( &mc->mc_candidates[ mc->mc_ntargets ], 0,
+                       sizeof( SlapReply ) * ( mi->mi_ntargets - mc->mc_ntargets ) );
+               mc->mc_ntargets = mi->mi_ntargets;
        }
 
        return mc->mc_candidates;