[hafqa] [hafqa] [Bug 1276] New: wrong allocators used in hildon_window_get_borders

From: bugzilla-daemon at maemo.org bugzilla-daemon at maemo.org
Date: Tue May 1 15:40:11 EEST 2007
https://maemo.org/bugzilla/show_bug.cgi?id=1276

           Summary: wrong allocators used in hildon_window_get_borders
           Product: haf
           Version: unspecified
          Platform: All
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: hildon-libs
        AssignedTo: michael.kostrzewa at nokia.com
        ReportedBy: chpe at gnome.org
         QAContact: hafqa at maemo.org


hildon_window_get_borders :

    g_free (priv->borders);
    g_free (priv->toolbar_borders);

    gtk_widget_style_get (GTK_WIDGET (window), "borders",&priv->borders,
            "toolbar-borders", &priv->toolbar_borders,
            NULL);

    if (! priv->borders)
        priv->borders = (GtkBorder *) g_malloc0 (sizeof (GtkBorder));

    if (! priv->toolbar_borders)
        priv->toolbar_borders = (GtkBorder *) g_malloc0 (sizeof (GtkBorder));

In gtk 2.11, GtkBorder is allocated with GSlice
[http://bugzilla.gnome.org/show_bug.cgi?id=383557]. So if the pointer was from
gtk_widget_style_get, it'll be allocated with GSlice, but in the failing case
you use g_malloc0, and you use g_free to free it. 

IMHO storing a GtkBorder instead of a GtkBorder* in HildonWindowPrivate, and doing

GtkBorder *border = NULL;
gtk_widget_style_get (widget, "borders", &border, ...)
if (border != NULL) {
  priv->border = *border;
  gtk_border_free (border);
}
else
  memset (&priv->border, 0, sizeof (GtkBorder));

would be the simplest solution.

I haven't checked whether the same problem occurs in other parts of the code.

-- 
Configure bugmail: https://maemo.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

More information about the hafqa mailing list