diff options
author | Arnavion <arnavion@gmail.com> | 2015-01-14 16:29:03 -0800 |
---|---|---|
committer | Arnavion <arnavion@gmail.com> | 2015-01-14 16:29:03 -0800 |
commit | 1d316710ed7699a43ffe8a889da7680cbb2d57f3 (patch) | |
tree | 87808d3b33a2b4e76857e892b955ffb01d74169c /src | |
parent | aab243592f9a72682216dfeeaa891200a79ac0a1 (diff) |
Don't crash if the log file can't be opened.
Found in #1269
Diffstat (limited to 'src')
-rw-r--r-- | src/common/text.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common/text.c b/src/common/text.c index 729f18dd..11a4595a 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -707,7 +707,9 @@ log_write (session *sess, char *text, time_t ts) } if (sess->logfd == -1) + { log_open (sess); + } /* change to a different log file? */ file = log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); @@ -715,12 +717,22 @@ log_write (session *sess, char *text, time_t ts) { if (g_access (file, F_OK) != 0) { - close (sess->logfd); + if (sess->logfd != -1) + { + close (sess->logfd); + } + sess->logfd = log_open_file (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); } + g_free (file); } + if (sess->logfd == -1) + { + return; + } + if (prefs.hex_stamp_log) { if (!ts) ts = time(0); @@ -731,6 +743,7 @@ log_write (session *sess, char *text, time_t ts) g_free (stamp); } } + temp = strip_color (text, -1, STRIP_ALL); len = strlen (temp); write (sess->logfd, temp, len); |