Comment 45 for bug 206191

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

Created attachment 334243
Christopher's version with test and Assign

(In reply to comment #17)
> >+ gchar *colorString = gdk_color_to_string(&color);
> >+ aResult.Adopt(colorString);
> >+ g_free(colorString);
>
> Shouldn't you copy the string here?

yeah, adopting doesn't look right according to the comment in ./string/public/nsXPCOMStrings.h:
  /* Data passed into NS_StringContainerInit2 is not copied; instead, the
   * string takes ownership over the data pointer. The caller must have
   * allocated the data array using the XPCOM memory allocator (nsMemory).
   * This flag should not be combined with NS_STRING_CONTAINER_INIT_DEPEND. */
  NS_STRING_CONTAINER_INIT_ADOPT = (1 << 2),

And I'm getting glibc double free errors with it. I've replaced it with Assign and added the tests.