summaryrefslogtreecommitdiff
path: root/gtk/gtkgrid.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-02-17 11:51:16 -0500
committerMatthias Clasen <mclasen@redhat.com>2011-02-17 11:53:38 -0500
commit169282959410c23d63db0a7ded81567ea7918120 (patch)
treef831eeae3c55026e9234097a8ded09270be19a7a /gtk/gtkgrid.c
parentda93864f5859e3811a4bd49072ba334a5ca8323a (diff)
downloadgtk+-169282959410c23d63db0a7ded81567ea7918120.tar.gz
GtkGrid: Avoid problems with uninitialized memory
valgrind complained about these, and they make for bad size allocation and the occasional crash.
Diffstat (limited to 'gtk/gtkgrid.c')
-rw-r--r--gtk/gtkgrid.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index 5639c2a7c0..bd305f6d46 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -20,6 +20,8 @@
#include "config.h"
+#include <string.h>
+
#include "gtkgrid.h"
#include "gtkorientableprivate.h"
@@ -1061,6 +1063,7 @@ gtk_grid_get_size (GtkGrid *grid,
gtk_grid_request_count_lines (&request);
lines = &request.lines[orientation];
lines->lines = g_newa (GtkGridLine, lines->max - lines->min);
+ memset (lines->lines, 0, (lines->max - lines->min) * sizeof (GtkGridLine));
gtk_grid_request_run (&request, orientation, FALSE);
gtk_grid_request_sum (&request, orientation, minimum, natural);
@@ -1081,8 +1084,10 @@ gtk_grid_get_size_for_size (GtkGrid *grid,
gtk_grid_request_count_lines (&request);
lines = &request.lines[0];
lines->lines = g_newa (GtkGridLine, lines->max - lines->min);
+ memset (lines->lines, 0, (lines->max - lines->min) * sizeof (GtkGridLine));
lines = &request.lines[1];
lines->lines = g_newa (GtkGridLine, lines->max - lines->min);
+ memset (lines->lines, 0, (lines->max - lines->min) * sizeof (GtkGridLine));
gtk_grid_request_run (&request, 1 - orientation, FALSE);
gtk_grid_request_sum (&request, 1 - orientation, &min_size, NULL);
@@ -1218,11 +1223,14 @@ gtk_grid_size_allocate (GtkWidget *widget,
GtkGridLines *lines;
request.grid = grid;
+
gtk_grid_request_count_lines (&request);
lines = &request.lines[0];
lines->lines = g_newa (GtkGridLine, lines->max - lines->min);
+ memset (lines->lines, 0, (lines->max - lines->min) * sizeof (GtkGridLine));
lines = &request.lines[1];
lines->lines = g_newa (GtkGridLine, lines->max - lines->min);
+ memset (lines->lines, 0, (lines->max - lines->min) * sizeof (GtkGridLine));
gtk_widget_set_allocation (widget, allocation);