diff options
| author | Jan Djärv | 2003-01-27 19:36:10 +0000 |
|---|---|---|
| committer | Jan Djärv | 2003-01-27 19:36:10 +0000 |
| commit | 0a1d6de043b7b9fa11f0c8eb258bbd27679ae8f9 (patch) | |
| tree | 4f58e2e867d9330c4d07b9f5d757e422c786a0bb /src | |
| parent | 839aacc98f3ffa7b609fa75f7a9963dda55acbc6 (diff) | |
| download | emacs-0a1d6de043b7b9fa11f0c8eb258bbd27679ae8f9.tar.gz emacs-0a1d6de043b7b9fa11f0c8eb258bbd27679ae8f9.zip | |
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/gtkutil.c | 37 |
2 files changed, 32 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 69854a306cb..90e21f34142 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2003-01-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * gtkutil.c (create_dialog, xg_separator_p) | ||
| 4 | (xg_item_label_same_p, xg_update_menu_item): Check for NULL string | ||
| 5 | before calling strcmp or strlen. | ||
| 6 | |||
| 1 | 2003-01-26 Jan D. <jan.h.d@swipnet.se> | 7 | 2003-01-26 Jan D. <jan.h.d@swipnet.se> |
| 2 | 8 | ||
| 3 | * gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display | 9 | * gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display |
diff --git a/src/gtkutil.c b/src/gtkutil.c index d8d1e36a8a6..99a6fe27005 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -759,7 +759,7 @@ create_dialog (wv, select_cb, deactivate_cb) | |||
| 759 | GtkWidget *w; | 759 | GtkWidget *w; |
| 760 | GtkRequisition req; | 760 | GtkRequisition req; |
| 761 | 761 | ||
| 762 | if (strcmp (item->name, "message") == 0) | 762 | if (item->name && strcmp (item->name, "message") == 0) |
| 763 | { | 763 | { |
| 764 | /* This is the text part of the dialog. */ | 764 | /* This is the text part of the dialog. */ |
| 765 | w = gtk_label_new (utf8_label); | 765 | w = gtk_label_new (utf8_label); |
| @@ -776,7 +776,7 @@ create_dialog (wv, select_cb, deactivate_cb) | |||
| 776 | gtk_widget_size_request (w, &req); | 776 | gtk_widget_size_request (w, &req); |
| 777 | gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (wdialog)->vbox), | 777 | gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (wdialog)->vbox), |
| 778 | req.height); | 778 | req.height); |
| 779 | if (strlen (item->value) > 0) | 779 | if (item->value && strlen (item->value) > 0) |
| 780 | button_spacing = 2*req.width/strlen (item->value); | 780 | button_spacing = 2*req.width/strlen (item->value); |
| 781 | } | 781 | } |
| 782 | else | 782 | else |
| @@ -1201,8 +1201,10 @@ make_menu_item (utf8_label, utf8_key, item, group) | |||
| 1201 | static int | 1201 | static int |
| 1202 | xg_separator_p (char *name) | 1202 | xg_separator_p (char *name) |
| 1203 | { | 1203 | { |
| 1204 | if (! name) return 0; | ||
| 1205 | |||
| 1204 | return strcmp (name, "--") == 0 | 1206 | return strcmp (name, "--") == 0 |
| 1205 | || strcmp (name, "--:") == 0 | 1207 | || strncmp (name, "--:", 3) == 0 |
| 1206 | || strcmp (name, "---") == 0; | 1208 | || strcmp (name, "---") == 0; |
| 1207 | } | 1209 | } |
| 1208 | 1210 | ||
| @@ -1539,6 +1541,7 @@ xg_create_widget (type, name, f, val, | |||
| 1539 | return w; | 1541 | return w; |
| 1540 | } | 1542 | } |
| 1541 | 1543 | ||
| 1544 | /* Return the label for menu item WITEM. */ | ||
| 1542 | static const char * | 1545 | static const char * |
| 1543 | xg_get_menu_item_label (witem) | 1546 | xg_get_menu_item_label (witem) |
| 1544 | GtkMenuItem *witem; | 1547 | GtkMenuItem *witem; |
| @@ -1547,16 +1550,22 @@ xg_get_menu_item_label (witem) | |||
| 1547 | return gtk_label_get_label (wlabel); | 1550 | return gtk_label_get_label (wlabel); |
| 1548 | } | 1551 | } |
| 1549 | 1552 | ||
| 1553 | /* Return non-zero if the menu item WITEM has the text LABEL. */ | ||
| 1550 | static int | 1554 | static int |
| 1551 | xg_item_label_same_p (witem, label) | 1555 | xg_item_label_same_p (witem, label) |
| 1552 | GtkMenuItem *witem; | 1556 | GtkMenuItem *witem; |
| 1553 | char *label; | 1557 | char *label; |
| 1554 | { | 1558 | { |
| 1555 | int is_same; | 1559 | int is_same = 0; |
| 1556 | char *utf8_label = get_utf8_string (label); | 1560 | char *utf8_label = get_utf8_string (label); |
| 1557 | 1561 | const char *old_label = witem ? xg_get_menu_item_label (witem) : 0; | |
| 1558 | is_same = strcmp (utf8_label, xg_get_menu_item_label (witem)) == 0; | 1562 | |
| 1559 | if (utf8_label != label) g_free (utf8_label); | 1563 | if (! old_label && ! utf8_label) |
| 1564 | is_same = 1; | ||
| 1565 | else if (old_label && utf8_label) | ||
| 1566 | is_same = strcmp (utf8_label, old_label) == 0; | ||
| 1567 | |||
| 1568 | if (utf8_label && utf8_label != label) g_free (utf8_label); | ||
| 1560 | 1569 | ||
| 1561 | return is_same; | 1570 | return is_same; |
| 1562 | } | 1571 | } |
| @@ -1773,6 +1782,8 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |||
| 1773 | GtkLabel *wkey = 0; | 1782 | GtkLabel *wkey = 0; |
| 1774 | char *utf8_label; | 1783 | char *utf8_label; |
| 1775 | char *utf8_key; | 1784 | char *utf8_key; |
| 1785 | const char *old_label = 0; | ||
| 1786 | const char *old_key = 0; | ||
| 1776 | xg_menu_item_cb_data *cb_data; | 1787 | xg_menu_item_cb_data *cb_data; |
| 1777 | 1788 | ||
| 1778 | wchild = gtk_bin_get_child (GTK_BIN (w)); | 1789 | wchild = gtk_bin_get_child (GTK_BIN (w)); |
| @@ -1812,14 +1823,18 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |||
| 1812 | } | 1823 | } |
| 1813 | } | 1824 | } |
| 1814 | 1825 | ||
| 1815 | if (utf8_key && strcmp (utf8_key, gtk_label_get_label (wkey)) != 0) | 1826 | |
| 1827 | if (wkey) old_key = gtk_label_get_label (wkey); | ||
| 1828 | if (wlbl) old_label = gtk_label_get_label (wlbl); | ||
| 1829 | |||
| 1830 | if (wkey && utf8_key && (! old_key || strcmp (utf8_key, old_key) != 0)) | ||
| 1816 | gtk_label_set_text (wkey, utf8_key); | 1831 | gtk_label_set_text (wkey, utf8_key); |
| 1817 | 1832 | ||
| 1818 | if (strcmp (utf8_label, gtk_label_get_label (wlbl)) != 0) | 1833 | if (! old_label || strcmp (utf8_label, old_label) != 0) |
| 1819 | gtk_label_set_text_with_mnemonic (wlbl, utf8_label); | 1834 | gtk_label_set_text_with_mnemonic (wlbl, utf8_label); |
| 1820 | 1835 | ||
| 1821 | if (utf8_key != val->key) g_free (utf8_key); | 1836 | if (utf8_key && utf8_key != val->key) g_free (utf8_key); |
| 1822 | if (utf8_label != val->name) g_free (utf8_label); | 1837 | if (utf8_label && utf8_label != val->name) g_free (utf8_label); |
| 1823 | 1838 | ||
| 1824 | if (! val->enabled && GTK_WIDGET_SENSITIVE (w)) | 1839 | if (! val->enabled && GTK_WIDGET_SENSITIVE (w)) |
| 1825 | gtk_widget_set_sensitive (w, FALSE); | 1840 | gtk_widget_set_sensitive (w, FALSE); |