Fix crash bug in on_transport_log.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 13 Apr 2009 16:05:13 +0000 (18:05 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 13 Apr 2009 16:05:13 +0000 (18:05 +0200)
NEWS
libirc/connection.c

diff --git a/NEWS b/NEWS
index c2fb7e1be5d19833671a1cd13316c417da5902a8..091accd465d5c4b07c513692134832fd388e56e8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,8 @@ Ctrlproxy 3.0.9 UNRELEASED
 
        * Fix netsplits generated when connection to a network is lost.
 
+       * Fix crash in on_transport_log when no error is set. (#219)
+
   FEATURES
 
     * Provide Python bindings for the main library code. Mainly used for 
index 1b7a4fa0d73354397bd9bbbbe91bb1598c9fd4fd..0067bf04bc0fd7df816b4219a78245365220de41 100644 (file)
@@ -143,9 +143,14 @@ static gboolean on_transport_recv(struct irc_transport *transport,
 static void on_transport_log(struct irc_transport *transport, const struct irc_line *l, const GError *error)
 {
        struct irc_network *network = transport->userdata;
-
-       network_log(LOG_WARNING, network, "Error while sending line '%s': %s", 
-                               l->args[0], error->message);
+       const char *errmsg = (error == NULL)?"UNKNOWN":error->message;
+
+       if (l->argc == 0)
+               network_log(LOG_WARNING, network, "Error while sending empty line: %s", 
+                                errmsg);
+       else
+               network_log(LOG_WARNING, network, "Error while sending line '%s': %s", 
+                               l->args[0], errmsg);
 }
 
 static const struct irc_transport_callbacks network_callbacks = {