evolution 2.28.4 segfaults in eti_row_height_real: check some variables

From: Thomas Mittelstaedt <tmstaedt@t-mittelstaedt.de>


---

 widgets/table/e-table-item.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)


diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index d009774..a0330b1 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -610,15 +610,16 @@ eti_remove_header_model (ETableItem *eti)
 static gint
 eti_row_height_real (ETableItem *eti, gint row)
 {
-	const gint cols = e_table_header_count (eti->header);
+	gint cols = 0; 
 	gint col;
 	gint h, max_h;
 
+	cols = e_table_header_count (eti->header);
 	g_return_val_if_fail (cols == 0 || eti->cell_views, 0);
 
 	max_h = 0;
 
-	for (col = 0; col < cols; col++) {
+	for (col = 0; eti->cell_views && col < cols; col++) {
 		h = e_cell_height (eti->cell_views [col], view_to_model_col(eti, col), col, row);
 
 		if (h > max_h)
@@ -704,8 +705,10 @@ eti_row_height (ETableItem *eti, gint row)
 	} else {
 		if (!eti->height_cache) {
 			calculate_height_cache (eti);
+			if (!eti->height_cache)
+				return 0;
 		}
-		if (eti->height_cache[row] == -1) {
+		if (eti->height_cache && eti->height_cache[row] == -1) {
 			eti->height_cache[row] = eti_row_height_real(eti, row);
 			if (row > 0 &&
 			    eti->length_threshold != -1 &&
@@ -715,7 +718,7 @@ eti_row_height (ETableItem *eti, gint row)
 				e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(eti));
 			}
 		}
-		return eti->height_cache[row];
+		return eti->height_cache ? eti->height_cache[row] : 0;
 	}
 }
 
@@ -1943,7 +1946,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gint x, gint y, gint wid
 			     "cursor_row", &cursor_row,
 			     NULL);
 
-		for (col = first_col; col < last_col; col++) {
+		for (col = first_col; (col < last_col) && (eti->cell_views != NULL) && (eti->header != NULL); col++) {
 			ETableCol *ecol = e_table_header_get_column (eti->header, col);
 			ECellView *ecell_view = eti->cell_views [col];
 			gboolean col_selected = selected;
