From: Pierangelo Masarati Date: Mon, 3 Sep 2007 16:27:01 +0000 (+0000) Subject: fix one-time leak (coverity) X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9beb9f9f51c5f2810881c6d1a4471eb1964dd063;p=openldap fix one-time leak (coverity) --- diff --git a/servers/slapd/overlays/memberof.c b/servers/slapd/overlays/memberof.c index 48b7f1a236..5bbe2a2dbf 100644 --- a/servers/slapd/overlays/memberof.c +++ b/servers/slapd/overlays/memberof.c @@ -1441,14 +1441,12 @@ memberof_db_init( ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; - memberof_t *mo; + memberof_t tmp_mo = { 0 }, *mo; int rc; const char *text = NULL; - mo = (memberof_t *)ch_calloc( 1, sizeof( memberof_t ) ); - - rc = slap_str2ad( SLAPD_MEMBEROF_ATTR, &mo->mo_ad_memberof, &text ); + rc = slap_str2ad( SLAPD_MEMBEROF_ATTR, &tmp_mo.mo_ad_memberof, &text ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "memberof_db_init: " @@ -1457,7 +1455,7 @@ memberof_db_init( return rc; } - rc = slap_str2ad( SLAPD_GROUP_ATTR, &mo->mo_ad_member, &text ); + rc = slap_str2ad( SLAPD_GROUP_ATTR, &tmp_mo.mo_ad_member, &text ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "memberof_db_init: " @@ -1466,8 +1464,8 @@ memberof_db_init( return rc; } - mo->mo_oc_group = oc_find( SLAPD_GROUP_CLASS ); - if ( mo->mo_oc_group == NULL ) { + tmp_mo.mo_oc_group = oc_find( SLAPD_GROUP_CLASS ); + if ( tmp_mo.mo_oc_group == NULL ) { Debug( LDAP_DEBUG_ANY, "memberof_db_init: " "unable to find objectClass=\"%s\"\n", @@ -1475,6 +1473,9 @@ memberof_db_init( return 1; } + mo = (memberof_t *)ch_calloc( 1, sizeof( memberof_t ) ); + *mo = tmp_mo; + on->on_bi.bi_private = (void *)mo; return 0;