summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Coval <philippe.coval@open.eurogiciel.org>2014-08-11 14:56:21 +0200
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>2014-08-11 14:56:21 +0200
commit2f3b4d2229a5c2c9d38cee00cff0697f4ed79190 (patch)
treec3c90f5a8c267218097903e783629d59d0095935
parentf1e4707d5041a246db46481cc87e49904e0cb681 (diff)
downloadlibwlmessage-2f3b4d2229a5c2c9d38cee00cff0697f4ed79190.tar.gz
libwlmessage-2f3b4d2229a5c2c9d38cee00cff0697f4ed79190.tar.bz2
libwlmessage-2f3b4d2229a5c2c9d38cee00cff0697f4ed79190.zip
fix: prevent crash
when started as: wlmessage -titlebuttons Min Change-Id: I75c9d9cf0953205a5b61f8aae7baa77341f0c5a6 Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> Author: Philippe Coval <philippe.coval@open.eurogiciel.org>
-rw-r--r--libwlmessage.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libwlmessage.c b/libwlmessage.c
index ca828c8..7ee564e 100644
--- a/libwlmessage.c
+++ b/libwlmessage.c
@@ -71,10 +71,11 @@ get_number_of_lines (char *text)
gchar **lines = g_strsplit (text, "\n", -1);
- while ((lines[lines_num] != NULL) && (lines_num < MAX_LINES))
- lines_num++;
-
- g_strfreev (lines);
+ if (lines) {
+ while ((lines[lines_num] != NULL) && (lines_num < MAX_LINES))
+ lines_num++;
+ g_strfreev (lines);
+ }
return lines_num;
}
@@ -87,14 +88,15 @@ get_max_length_of_lines (char *text)
gchar **lines = g_strsplit (text, "\n", -1);
- while ((lines[lines_num] != NULL) && (lines_num < MAX_LINES)) {
- if (strlen (lines[lines_num]) > length)
- length = strlen (lines[lines_num]);
- lines_num++;
+ if (lines) {
+ while ((lines[lines_num] != NULL) && (lines_num < MAX_LINES)) {
+ if (strlen (lines[lines_num]) > length)
+ length = strlen (lines[lines_num]);
+ lines_num++;
+ }
+ g_strfreev (lines);
}
- g_strfreev (lines);
-
return length;
}