]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapcommon.c
Happy New Year
[openldap] / servers / slapd / slapcommon.c
index 153310f2916b262c2374bc19c4d187c67b9bf579..29152803c27dacfc88346474f443939a32f41534 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2013 The OpenLDAP Foundation.
+ * Copyright 1998-2018 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
@@ -441,6 +441,7 @@ slap_tool_init(
                        }
 
                        if ( ludp->lud_dn != NULL && ludp->lud_dn[0] != '\0' ) {
+                               ch_free( subtree );
                                subtree = ludp->lud_dn;
                                ludp->lud_dn = NULL;
                        }
@@ -527,6 +528,7 @@ slap_tool_init(
                        case SLAPCAT:
                        case SLAPSCHEMA:
                                /* dump subtree */
+                               ch_free( subtree );
                                subtree = ch_strdup( optarg );
                                break;
                        }
@@ -786,6 +788,11 @@ slap_tool_init(
                ber_memfree( nbase.bv_val );
                BER_BVZERO( &nbase );
 
+               if( be == NULL ) {
+                       fprintf( stderr, "%s: slap_init no backend for \"%s\"\n",
+                               progname, base.bv_val );
+                       exit( EXIT_FAILURE );
+               }
                switch ( tool ) {
                case SLAPACL:
                        goto startup;
@@ -794,11 +801,6 @@ slap_tool_init(
                        break;
                }
 
-               if( be == NULL ) {
-                       fprintf( stderr, "%s: slap_init no backend for \"%s\"\n",
-                               progname, base.bv_val );
-                       exit( EXIT_FAILURE );
-               }
                /* If the named base is a glue master, operate on the
                 * entire context
                 */
@@ -1003,6 +1005,7 @@ slap_tool_update_ctxcsn(
                                fprintf( stderr, "%s: couldn't create context entry\n", progname );
                                rc = EXIT_FAILURE;
                        }
+                       entry_free( ctxcsn_e );
                } else {
                        fprintf( stderr, "%s: context entry is missing\n", progname );
                        rc = EXIT_FAILURE;
@@ -1010,9 +1013,14 @@ slap_tool_update_ctxcsn(
        } else {
                ctxcsn_e = be->be_entry_get( be, ctxcsn_id );
                if ( ctxcsn_e != NULL ) {
+                       Operation op = { 0 };
                        Entry *e = entry_dup( ctxcsn_e );
-                       int change;
                        Attribute *attr = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
+
+                       int change;
+                       op.o_bd = be;
+                       be_entry_release_r( &op, ctxcsn_e );
+
                        if ( attr ) {
                                int             i;