Re: [evolution-patches] Bug 45210 - LDAP PostalAddress compliance patch for evolution-data-server, contacts



On Mon, 2004-05-03 at 12:39, Chris Toshok wrote:
> On Sun, 2004-05-02 at 13:37 -0500, Edward Rudd wrote:
> > Here is an updated version of my patch to fix the storage postalAddress
> > fields in LDAP.  This is based off of evolution-data-server CVS HEAD.
> 
> 
> +struct berval **
> +address_ber(EContact * card, EContactField field)
> +{
> +       struct berval **result = NULL;
> +       const char *address;
> +       char *temp, *i;
> +
> +       address = e_contact_get(card, field);
> +       if (address) {
> +               temp = g_strdup(address);
> +               for (i = temp; *i != '\0'; i++) {
> +                       if (*i == '\n') {
> +                               *i = '$';
> +                       }
> +               }
> +
> +               result = g_new(struct berval *, 2);
> +               result[0] = g_new(struct berval, 1);
> +               result[0]->bv_val = temp;
> +               result[0]->bv_len = strlen(temp);
> +
> +               result[1] = NULL;
> +       }
> +       return result;
> +}
> 
> So this will leak the label - the memory you get back from e_contact_get
> is to be freed anyway, so just removing temp and using address in its
> place should fix things.
> 
Well, from tacking down what e_contact_get does, returns a gpointer
retrieved from g_object_get, and not a copy of the structure. And all
the other *_ber functions for complex type handling never touch the data
retrieved from e_contact_get and type them as const char *, and they
always make a copy which they place in the (berval*)->bv-val.  Therefore
no leak is happening at all as I am putting the fixed temp var directly
into the berval stucture. 

> Other than that, this looks fine.
> 
> Chris
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
-- 
Edward Rudd <eddie omegaware com>
Website http://www.outoforder.cc/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]