diff libpurple/util.c @ 24216:9ee331d042c8

Trigger url_fetch_connect_cb() asynchronously when the connection fails immediately instead of synchronously calling the callback and then returning NULL, causing a double free. Fixes #7278
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 21 Oct 2008 16:09:23 +0000
parents fa39c801167d
children 3ef4625689e0 6ebabe0841a0 15d6ae92aeb4
line wrap: on
line diff
--- a/libpurple/util.c	Tue Oct 21 16:01:13 2008 +0000
+++ b/libpurple/util.c	Tue Oct 21 16:09:23 2008 +0000
@@ -3979,6 +3979,13 @@
 					     callback, user_data);
 }
 
+static gboolean
+url_fetch_connect_failed(gpointer data)
+{
+	url_fetch_connect_cb(data, -1, "");
+	return FALSE;
+}
+
 PurpleUtilFetchUrlData *
 purple_util_fetch_url_request_len(const char *url, gboolean full,
 		const char *user_agent, gboolean http11,
@@ -4016,9 +4023,8 @@
 
 	if (gfud->connect_data == NULL)
 	{
-		purple_util_fetch_url_error(gfud, _("Unable to connect to %s"),
-				gfud->website.address);
-		return NULL;
+		/* Trigger the connect_cb asynchronously. */
+		purple_timeout_add(10, url_fetch_connect_failed, gfud);
 	}
 
 	return gfud;