changeset 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 1263f302d05e
children 21caa58da895
files libpurple/util.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
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;