From 894e887370bc1b9f9f2e085e681b422448d50a54 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Sat, 3 Apr 2010 19:48:14 -0400 Subject: [PATCH] Fixed GtkCellRendererText invalid pointer access. Fixed get_desired_size() to not access parameters when NULL and also not to access priv->object if it hasnt yet been assigned. --- gtk/gtkcellrenderertext.c | 50 ++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 8529c089cc..37c5eb765a 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -1946,25 +1946,43 @@ gtk_cell_renderer_text_extended_layout_get_desired_size (GtkExtendedLayout *layo priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (layout); - if (minimal_size) + if (priv->owner) { - get_size (GTK_CELL_RENDERER (layout), - priv->owner, NULL, NULL, NULL, NULL, - &minimal_size->width, &minimal_size->height); + + if (minimal_size) + { + get_size (GTK_CELL_RENDERER (layout), + priv->owner, NULL, NULL, NULL, NULL, + &minimal_size->width, &minimal_size->height); + } + + if (desired_size) + { + PangoEllipsizeMode ellipsize; + + ellipsize = priv->ellipsize; + priv->ellipsize = PANGO_ELLIPSIZE_NONE; + + get_size (GTK_CELL_RENDERER (layout), + priv->owner, NULL, NULL, NULL, NULL, + &desired_size->width, &desired_size->height); + + priv->ellipsize = ellipsize; + } } - - if (desired_size) + else { - PangoEllipsizeMode ellipsize; - - ellipsize = priv->ellipsize; - priv->ellipsize = PANGO_ELLIPSIZE_NONE; - - get_size (GTK_CELL_RENDERER (layout), - priv->owner, NULL, NULL, NULL, NULL, - &desired_size->width, &desired_size->height); - - priv->ellipsize = ellipsize; + if (minimal_size) + { + minimal_size->height = 0; + minimal_size->width = 0; + } + + if (desired_size) + { + desired_size->height = 0; + desired_size->width = 0; + } } }