[gtk+/a11y] Don't pass NULL to functions expecing a real string
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] Don't pass NULL to functions expecing a real string
- Date: Wed, 22 Jun 2011 03:32:04 +0000 (UTC)
commit e95ab86397973c9ddfa4a9e1adee887713bada44
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 21 23:30:38 2011 -0400
Don't pass NULL to functions expecing a real string
...and when you do pass them a real string, don't leak it.
gtk/a11y/gailmenuitem.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gtk/a11y/gailmenuitem.c b/gtk/a11y/gailmenuitem.c
index dd680ca..4186e03 100644
--- a/gtk/a11y/gailmenuitem.c
+++ b/gtk/a11y/gailmenuitem.c
@@ -240,7 +240,7 @@ static void
gail_menu_item_init_textutil (GailMenuItem *item,
GtkWidget *label)
{
- const gchar *label_text;
+ gchar *label_text;
if (item->textutil == NULL)
{
@@ -251,7 +251,8 @@ gail_menu_item_init_textutil (GailMenuItem *item,
item);
}
label_text = get_text_from_label_widget (label);
- gail_text_util_text_setup (item->textutil, label_text);
+ gail_text_util_text_setup (item->textutil, label_text ? label_text : "");
+ g_free (label_text);
}
/* atktext.h */
@@ -279,7 +280,7 @@ gail_menu_item_get_text (AtkText *text,
GtkWidget *widget;
GtkWidget *label;
GailMenuItem *item;
- const gchar *label_text;
+ gchar *label_text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@@ -297,8 +298,12 @@ gail_menu_item_get_text (AtkText *text,
if (label_text == NULL)
return NULL;
else
- return gail_text_util_get_substring (item->textutil,
- start_pos, end_pos);
+ {
+ g_free (label_text);
+
+ return gail_text_util_get_substring (item->textutil,
+ start_pos, end_pos);
+ }
}
static gchar*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]