SoupLogger: don't crash if the session emits bogus data
authorDan Winship <danw@gnome.org>
Sat, 10 Apr 2010 16:10:07 +0000 (12:10 -0400)
committerDan Winship <danw@gnome.org>
Sat, 10 Apr 2010 16:12:09 +0000 (12:12 -0400)
In general, if the data being passed to SoupLogger is bad, the app is
probably going to crash soon anyway, but we'd rather have it crash
somewhere "real", not in the debugging code.

https://bugzilla.gnome.org/show_bug.cgi?id=611663

libsoup/soup-logger.c

index 089a505..7cdf2ed 100644 (file)
@@ -17,6 +17,7 @@
 #include "soup-message.h"
 #include "soup-session.h"
 #include "soup-session-feature.h"
+#include "soup-socket.h"
 #include "soup-uri.h"
 
 /**
@@ -621,6 +622,8 @@ static void
 request_queued (SoupSessionFeature *logger, SoupSession *session,
                SoupMessage *msg)
 {
+       g_return_if_fail (SOUP_IS_MESSAGE (msg));
+
        g_signal_connect (msg, "got-informational",
                          G_CALLBACK (got_informational),
                          logger);
@@ -637,6 +640,10 @@ request_started (SoupSessionFeature *feature, SoupSession *session,
        gboolean restarted;
        guint msg_id;
 
+       g_return_if_fail (SOUP_IS_SESSION (session));
+       g_return_if_fail (SOUP_IS_MESSAGE (msg));
+       g_return_if_fail (SOUP_IS_SOCKET (socket));
+
        msg_id = soup_logger_get_id (logger, msg);
        if (msg_id)
                restarted = TRUE;
@@ -659,6 +666,8 @@ static void
 request_unqueued (SoupSessionFeature *logger, SoupSession *session,
                  SoupMessage *msg)
 {
+       g_return_if_fail (SOUP_IS_MESSAGE (msg));
+
        g_signal_handlers_disconnect_by_func (msg, got_informational, logger);
        g_signal_handlers_disconnect_by_func (msg, got_body, logger);
 }