From: Howard Chu Date: Thu, 2 Dec 2004 08:59:02 +0000 (+0000) Subject: Avoid segfault if backend_destroy is called before frontendDB is created X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~154 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f83b55b2a27561aa3467dc958ce84152e28a091a;p=openldap Avoid segfault if backend_destroy is called before frontendDB is created --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index bd03c49500..fb8fc0fe1b 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -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; }