[gnumeric] GUI: Fix crash when selecting invalid dates.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Fix crash when selecting invalid dates.
- Date: Mon, 26 Sep 2011 18:56:09 +0000 (UTC)
commit 46bf2d7e2bbc1053b1e4bded406305fc259a95fa
Author: Morten Welinder <terra gnome org>
Date: Mon Sep 26 14:55:45 2011 -0400
GUI: Fix crash when selecting invalid dates.
ChangeLog | 2 ++
NEWS | 1 +
src/gnm-format.c | 19 ++++++++++++++-----
3 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f9684b4..8f044ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2011-09-26 Morten Welinder <terra gnome org>
+ * src/gnm-format.c (hash_fill): Handle NULL str without crash.
+
* src/wbc-gtk-actions.c (cb_add_component_from_file): #if 0.
* src/main-application.c (call_gnome_authentication_manager_init):
diff --git a/NEWS b/NEWS
index cdccd91..10883c1 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ Morten:
* Fix crash. [#658140]
* Fix stf import crash. [#658982]
* Fix leaks.
+ * Fix GUI crash for invalid dates.
Valek:
* In xls import, set LABEL encoding based on FONT charset converted to
diff --git a/src/gnm-format.c b/src/gnm-format.c
index 1647941..e6dcd72 100644
--- a/src/gnm-format.c
+++ b/src/gnm-format.c
@@ -65,16 +65,25 @@ static void
hash_fill (PangoLayout *layout, GString *str, const GOFontMetrics *metrics, int col_width)
{
if (col_width <= 0) {
- g_string_truncate (str, 0);
- if (layout) pango_layout_set_text (layout, str->str, -1);
+ if (str) g_string_truncate (str, 0);
+ if (layout) pango_layout_set_text (layout, "", -1);
} else {
int l = metrics->hash_width > 0
? col_width / metrics->hash_width
: 1;
- g_string_set_size (str, l);
- memset (str->str, '#', str->len);
+ GString *hashstr;
+
+ if (str) {
+ hashstr = str;
+ g_string_truncate (hashstr, 0);
+ } else {
+ hashstr = g_string_sized_new (l);
+ }
+ go_string_append_c_n (hashstr, '#', l);
if (layout)
- pango_layout_set_text (layout, str->str, -1);
+ pango_layout_set_text (layout, hashstr->str, -1);
+ if (str != hashstr)
+ g_string_free (hashstr, TRUE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]