]> git.sur5r.net Git - openldap/commitdiff
Fix ldap_get_attribute_ber to get values in-place.
authorHoward Chu <hyc@openldap.org>
Wed, 14 May 2003 13:16:56 +0000 (13:16 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 14 May 2003 13:16:56 +0000 (13:16 +0000)
Revert previous memleak fix in ldapsearch.c

clients/tools/ldapsearch.c
libraries/libldap/getattr.c

index ec219867ec284aebc1c36e22ee8bd26c98ce07d3..daebef8ef5bf46828339fe24c3a3ae41e194c4b2 100644 (file)
@@ -1367,7 +1367,7 @@ print_entry(
                                                bvals[ i ].bv_val, bvals[ i ].bv_len );
                                }
                        }
-                       ber_bvarray_free( bvals );
+                       ber_memfree( bvals );
                }
        }
 
index 6e67e71c681434bf499c012023e3d0288727252e..bbe5020561e906c9478bf45fa94a67d21ffa268e 100644 (file)
@@ -121,7 +121,10 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
        return attr;
 }
 
-/* Fetch attribute type and optionally fetch values */
+/* Fetch attribute type and optionally fetch values. The type
+ * and values are referenced in-place from the BerElement, they are
+ * not dup'd into malloc'd memory.
+ */
 /* ARGSUSED */
 int
 ldap_get_attribute_ber( LDAP *ld, LDAPMessage *entry, BerElement *ber,
@@ -146,8 +149,11 @@ ldap_get_attribute_ber( LDAP *ld, LDAPMessage *entry, BerElement *ber,
        attr->bv_len = 0;
 
        if ( ber_pvt_ber_remaining( ber ) ) {
+               ber_len_t siz = sizeof( BerValue );
+
                /* skip sequence, snarf attribute type */
-               tag = ber_scanf( ber, vals ? "{mW}" : "{mx}", attr, vals ); 
+               tag = ber_scanf( ber, vals ? "{mM}" : "{mx}", attr, vals,
+                       &siz, 0 ); 
                if( tag == LBER_ERROR ) {
                        rc = ld->ld_errno = LDAP_DECODING_ERROR;
                }