[PATCH] Don't multiply by -1 when assigning memory



Hi

Attached patch fixes a problem I just found out. Running any GTK app
showed this:

GLib-ERROR **: gmem.c:143: failed to allocate 68719477360 bytes

I found the culprit to be the patched function, which was multiplying by
-1 when n_args was 0.

Ok to commit to HEAD?
-- 
Rodrigo Moya <rodrigo gnome-db org>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.7390
diff -u -p -r1.7390 ChangeLog
--- ChangeLog	4 Jan 2006 11:25:19 -0000	1.7390
+++ ChangeLog	4 Jan 2006 12:13:02 -0000
@@ -1,3 +1,8 @@
+2006-01-04  Rodrigo Moya <rodrigo novell com>
+
+	* gtk/gtkbindings.c (binding_signal_new): guard against multiplying
+	by -1 (when n_args is 0).
+
 2006-01-04  Michael Natterer  <mitch imendio com>
 
 	* gtk/gtkmenutoolbutton.c
Index: gtk/gtkbindings.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbindings.c,v
retrieving revision 1.49
diff -u -p -r1.49 gtkbindings.c
--- gtk/gtkbindings.c	28 Dec 2005 04:09:18 -0000	1.49
+++ gtk/gtkbindings.c	4 Jan 2006 12:13:02 -0000
@@ -65,7 +65,7 @@ binding_signal_new (const gchar *signal_
 {
   GtkBindingSignal *signal;
   
-  signal = (GtkBindingSignal *) g_malloc0 (sizeof (GtkBindingSignal) + (n_args - 1) * sizeof (GtkBindingArg));
+  signal = (GtkBindingSignal *) g_malloc0 (sizeof (GtkBindingSignal) + (n_args > 0 ? n_args - 1 : 0) * sizeof (GtkBindingArg));
   signal->next = NULL;
   signal->signal_name = (gchar *)g_intern_string (signal_name);
   signal->n_args = n_args;


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