From aa196c619caae5b1412aeffca4a95b794deaff38 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Apr 2009 18:05:13 +0200 Subject: [PATCH] Fix crash bug in on_transport_log. --- NEWS | 2 ++ libirc/connection.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index c2fb7e1..091accd 100644 --- 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 diff --git a/libirc/connection.c b/libirc/connection.c index 1b7a4fa..0067bf0 100644 --- a/libirc/connection.c +++ b/libirc/connection.c @@ -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 = { -- 2.34.1