]> git.sur5r.net Git - openldap/commitdiff
Avoid segfault if backend_destroy is called before frontendDB is created
authorHoward Chu <hyc@openldap.org>
Thu, 2 Dec 2004 08:59:02 +0000 (08:59 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 2 Dec 2004 08:59:02 +0000 (08:59 +0000)
servers/slapd/backend.c

index bd03c495009e50fcb296a67f1d2d2d6aa904e361..fb8fc0fe1bb129f53ee07ad88209b7e1726cb7d1 100644 (file)
@@ -445,15 +445,17 @@ int backend_destroy(void)
 
        /* destroy frontend database */
        bd = frontendDB;
-       if ( bd->bd_info->bi_db_destroy ) {
-               bd->bd_info->bi_db_destroy( bd );
+       if ( bd ) {
+               if ( bd->bd_info->bi_db_destroy ) {
+                       bd->bd_info->bi_db_destroy( bd );
+               }
+               ber_bvarray_free( bd->be_suffix );
+               ber_bvarray_free( bd->be_nsuffix );
+               if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
+               if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
+               if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
+               acl_destroy( bd->be_acl, frontendDB->be_acl );
        }
-       ber_bvarray_free( bd->be_suffix );
-       ber_bvarray_free( bd->be_nsuffix );
-       if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
-       if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
-       if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
-       acl_destroy( bd->be_acl, frontendDB->be_acl );
 
        return 0;
 }