]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/sssvlv.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_5
[openldap] / servers / slapd / overlays / sssvlv.c
index 674803e42fc73efd5deac513dd48263f22c5bdf3..10567799a124dd2780c5ee582a09d11cfe9ada24 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2009-2013 The OpenLDAP Foundation.
+ * Copyright 2009-2014 The OpenLDAP Foundation.
  * Portions copyright 2009 Symas Corporation.
  * All rights reserved.
  *
@@ -397,7 +397,19 @@ static void free_sort_op( Connection *conn, sort_op *so )
 {
        int sess_id;
        if ( so->so_tree ) {
-               tavl_free( so->so_tree, ch_free );
+               if ( so->so_paged > SLAP_CONTROL_IGNORED ) {
+                       Avlnode *cur_node, *next_node;
+                       cur_node = so->so_tree;
+                       while ( cur_node ) {
+                               next_node = tavl_next( cur_node, TAVL_DIR_RIGHT );
+                               ch_free( cur_node->avl_data );
+                               ber_memfree( cur_node );
+
+                               cur_node = next_node;
+                       }
+               } else {
+                       tavl_free( so->so_tree, ch_free );
+               }
                so->so_tree = NULL;
        }
 
@@ -618,6 +630,8 @@ static void send_page( Operation *op, SlapReply *rs, sort_op *so )
 
        /* Set the first entry to send for the next page */
        so->so_tree = next_node;
+       if ( next_node )
+               next_node->avl_left = NULL;
 
        op->o_bd = be;
 }