Fix error in computing length and a memory leak. (Fixes #94072, reported

Thu Oct  3 19:00:55 2002  Owen Taylor  <otaylor@redhat.com>

        * gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
        Fix error in computing length and a memory leak.
        (Fixes #94072, reported by Hema Seetharamaiah)

        * gtk/gtkmenu.c (gtk_menu_motion_notify): Fix &event
        used instead of event.
This commit is contained in:
Owen Taylor
2002-10-03 23:23:16 +00:00
committed by Owen Taylor
parent 12359a817b
commit 92fa223146
9 changed files with 95 additions and 21 deletions

View File

@ -295,35 +295,54 @@ gdk_selection_property_get (GdkWindow *requestor,
*ret_type = gdk_x11_xatom_to_atom_for_display (display, prop_type);
if (ret_format)
*ret_format = prop_format;
/* Add on an extra byte to handle null termination. X guarantees
that t will be 1 longer than nitems and null terminated */
length = nitems + 1;
if (data)
if (prop_type == XA_ATOM ||
prop_type == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
{
*data = g_new (guchar, length);
if (prop_type == XA_ATOM ||
prop_type == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
Atom* atoms = (Atom*) t;
GdkAtom* atoms_dest;
gint num_atom, i;
if (prop_format != 32)
goto err;
num_atom = nitems;
length = sizeof (GdkAtom) * num_atom + 1;
if (data)
{
Atom* atoms = (Atom*) t;
GdkAtom* atoms_dest;
gint num_atom, i;
num_atom = (length - 1) / sizeof (Atom);
length = sizeof (GdkAtom) * num_atom + 1;
*data = g_malloc (length);
(*data)[length - 1] = '\0';
atoms_dest = (GdkAtom *)(*data);
for (i=0; i < num_atom; i++)
atoms_dest[i] = gdk_x11_xatom_to_atom_for_display (display, atoms[i]);
}
else
}
else
{
switch (prop_format)
{
*data = g_memdup (t, length);
case 8:
length = nitems;
break;
case 16:
length = sizeof(short) * nitems;
break;
case 32:
length = sizeof(long) * nitems;
break;
default:
g_assert_not_reached ();
break;
}
/* Add on an extra byte to handle null termination. X guarantees
that t will be 1 longer than nitems and null terminated */
length += 1;
if (data)
*data = g_memdup (t, length);
}
if (t)