]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/oc.c
ITS#7588 fix double-free for sorted paged search
[openldap] / servers / slapd / oc.c
index 508a3edcf34b4ef817bdd7e2ed7f9e3e55e25899..b3d2d8a37c50483fe11fc1c307dc5849cb16f223 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2013 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -92,6 +92,9 @@ int is_entry_objectclass(
                        e->e_dn == NULL ? "" : e->e_dn,
                        oc->soc_oclass.oc_oid, 0 );
 
+               /* mark flags as set */
+               e->e_ocflags |= SLAP_OC__END;
+
                return 0;
        }
 
@@ -397,6 +400,8 @@ oc_delete_names( ObjectClass *oc )
 {
        char                    **names = oc->soc_names;
 
+       if (!names) return;
+
        while (*names) {
                struct oindexrec        tmpoir, *oir;
 
@@ -634,6 +639,8 @@ oc_insert(
                assert( oc_bvfind( &oir->oir_name ) != NULL );
        }
 
+       assert( soc != NULL );
+
        if ( (names = soc->soc_names) ) {
                while ( *names ) {
                        oir = (struct oindexrec *)
@@ -642,9 +649,6 @@ oc_insert(
                        oir->oir_name.bv_len = strlen( *names );
                        oir->oir_oc = soc;
 
-                       assert( oir->oir_name.bv_val != NULL );
-                       assert( oir->oir_oc != NULL );
-
                        if ( avl_insert( &oc_index, (caddr_t) oir,
                                oc_index_cmp, avl_dup_error ) )
                        {
@@ -804,6 +808,10 @@ done:;
                        ch_free( soc->soc_allowed );
                }
 
+               if ( soc->soc_oidmacro ) {
+                       ch_free( soc->soc_oidmacro );
+               }
+
                ch_free( soc );
 
        } else if ( rsoc ) {