Re: Strange glibc detected invalid pointer with gtk_entry



On 2011-07-05 at 15:05, zz excite it wrote:
void my_gtk_entry_set_text(GtkEntry *entry, char *data)
{
      char *tmp;

      if (!data) data = "";

      if (g_utf8_validate(data, -1, NULL) != TRUE) {
              tmp = g_locale_to_utf8(data, -1, NULL, NULL, NULL); 
              gtk_entry_set_text(entry, tmp);
              xfree(&tmp);
                ^^^^^^^^^^^^

agh!

g_locale_to_utf8() returns memory allocated through the GLib API; you
need to call g_free() to free it. *do not* mix GLib's memory allocation
functions with other allocation functions.

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi



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