[evolution-patches] gal, a11y, crash if table row=0



Hi Mike,

This is patch for HEAD, fix bug 51199, please review

When table has 0 rows , it is valid. But orignal code assert it as error. It cause a crash.

So the patch just modified the assertation and include 0 row case. And take care of cache alloc in this case.


Regards
York






Index: gal-a11y-e-table-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-item.c,v
retrieving revision 1.5
diff -u -r1.5 gal-a11y-e-table-item.c
--- gal-a11y-e-table-item.c	21 Nov 2003 04:28:04 -0000	1.5
+++ gal-a11y-e-table-item.c	24 Nov 2003 05:34:07 -0000
@@ -858,16 +858,19 @@
 	GET_PRIVATE (a11y)->parent = parent;
 	GET_PRIVATE (a11y)->index_in_parent = index_in_parent;
 
-	g_return_val_if_fail (item->cols > 0 && item->rows > 0, NULL);
+	g_return_val_if_fail (item->cols >= 0 && item->rows >= 0, NULL);
 	/* Initialize cell data. */
 	n = item->cols * item->rows;
 	GET_PRIVATE (a11y)->cols = item->cols;
 	GET_PRIVATE (a11y)->rows = item->rows;
-	GET_PRIVATE (a11y)->cell_data = g_malloc0(n*sizeof(gpointer));
-
-	/* memory error. */
-	if ( GET_PRIVATE (a11y) == NULL)
-		return NULL;
+	if (n > 0) {
+		GET_PRIVATE (a11y)->cell_data = g_malloc0(n*sizeof(gpointer));
+		/* memory error. */
+		if ( GET_PRIVATE (a11y)->cell_data == NULL)
+			return NULL;
+	} else
+		GET_PRIVATE (a11y)->cell_data = NULL;
+		
 
 	if (item) {
 		g_signal_connect (G_OBJECT(item), "selection_model_removed",


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