bug in gtk_label
- From: Michael Lausch <mla gams co at>
- To: gtk-devel-list redhat com
- Subject: bug in gtk_label
- Date: Wed, 16 Dec 1998 20:28:27 +0100
gtk_label_set_text() calls gdk_mbstowcs and uses it's return value as
an index into label->label_wc.
gdk_mbstowcs can return -1 (it does it on my setup because
XwcTextPropertyToTextList return a failure code) but this error is not
checked.
also the label_wc string is not freed when a new string is allocated.
The following patch should do something more reasonable:
Index: gtklabel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklabel.c,v
retrieving revision 1.30
diff -u -r1.30 gtklabel.c
--- gtklabel.c 1998/12/15 20:31:09 1.30
+++ gtklabel.c 1998/12/16 19:26:56
@@ -232,12 +232,15 @@
/* Convert text to wide characters */
len = strlen (str);
- label->label_wc = g_new (GdkWChar, len + 1);
+ if (label->label_wc)
+ g_free(label->label_wc);
+ label->label_wc = 0;
wc_len = gdk_mbstowcs (label->label_wc, str, len + 1);
- label->label_wc[wc_len] = '\0';
-
+ if (wc_len >= 0) {
+ label->label_wc = g_new (GdkWChar, len + 1);
+ label->label_wc[wc_len] = '\0';
+ }
gtk_label_free_words (label);
-
if (GTK_WIDGET_VISIBLE (label))
{
if (GTK_WIDGET_MAPPED (label))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]