]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/valsort.c
check for NULL backend (ITS#6490)
[openldap] / servers / slapd / overlays / valsort.c
index af239d8af006664b819e7f6184dd663921c94c42..53a2e9192535da475250b2de2277f6e8c8085861 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2005-2008 The OpenLDAP Foundation.
+ * Copyright 2005-2009 The OpenLDAP Foundation.
  * Portions copyright 2005 Symas Corporation.
  * All rights reserved.
  *
@@ -297,9 +297,19 @@ valsort_response( Operation *op, SlapReply *rs )
                a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad );
                if ( !a ) continue;
 
-               if (( rs->sr_flags & ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED )) !=
-                       ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED )) {
-                       rs->sr_entry = entry_dup( rs->sr_entry );
+               if (( rs->sr_flags & ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) ) !=
+                       ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) )
+               {
+                       Entry *e;
+
+                       e = entry_dup( rs->sr_entry );
+                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
+                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
+                               rs->sr_flags &= ~REP_ENTRY_MUSTRELEASE;
+                       } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
+                               entry_free( rs->sr_entry );
+                       }
+                       rs->sr_entry = e;
                        rs->sr_flags |= REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED;
                        a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad );
                }