From 625263852d1c762be5d132ab76d1cca2d1aa0c66 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 30 Jan 2005 23:12:27 +0000 Subject: [PATCH] fix previous commit; plug a long lasting leak --- servers/slapd/back-dnssrv/search.c | 38 +++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index 8bf56f5855..14734a7e67 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -169,7 +169,6 @@ dnssrv_back_search( send_ldap_error( op, rs, LDAP_SUCCESS, NULL ); } else { - struct berval vals[2]; Entry *e = ch_calloc( 1, sizeof(Entry) ); AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; @@ -182,38 +181,33 @@ dnssrv_back_search( e->e_attrs = NULL; e->e_private = NULL; - vals[1].bv_val = NULL; - - BER_BVSTR( &vals[0], "top" ); - attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_top->soc_cname ); - - BER_BVSTR( &vals[0], "referral" ); - attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_referral->soc_cname ); - - BER_BVSTR( &vals[0], "extensibleObject" ); - attr_mergeit( e, ad_objectClass, &slap_schema.si_oc_extensibleObject->soc_cname ); + attr_mergeit_one( e, ad_objectClass, &slap_schema.si_oc_top->soc_cname ); + attr_mergeit_one( e, ad_objectClass, &slap_schema.si_oc_referral->soc_cname ); + attr_mergeit_one( e, ad_objectClass, &slap_schema.si_oc_extensibleObject->soc_cname ); if ( ad_dc ) { - char *p; - vals[0].bv_val = ch_strdup( domain ); + char *p; + struct berval bv; - p = strchr( vals[0].bv_val, '.' ); + bv.bv_val = domain; + + p = strchr( bv.bv_val, '.' ); - if ( p == vals[0].bv_val ) { - vals[0].bv_val[1] = '\0'; + if ( p == bv.bv_val ) { + bv.bv_len = 1; } else if ( p != NULL ) { - *p = '\0'; + bv.bv_len = p - bv.bv_val; } - vals[0].bv_len = strlen( vals[0].bv_val ); - attr_mergeit( e, ad_dc, vals ); + attr_mergeit_one( e, ad_dc, &bv ); } if ( ad_associatedDomain ) { - vals[0].bv_val = domain; - vals[0].bv_len = strlen(domain); - attr_mergeit( e, ad_associatedDomain, vals ); + struct berval bv; + + ber_str2bv( domain, 0, 0, &bv ); + attr_mergeit_one( e, ad_associatedDomain, &bv ); } attr_mergeit( e, ad_ref, urls ); -- 2.39.5