comparison libpurple/util.c @ 24274: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
comparison
equal deleted inserted replaced
24273:1263f302d05e 24274:9ee331d042c8
3977 user_agent, http11, 3977 user_agent, http11,
3978 request, include_headers, -1, 3978 request, include_headers, -1,
3979 callback, user_data); 3979 callback, user_data);
3980 } 3980 }
3981 3981
3982 static gboolean
3983 url_fetch_connect_failed(gpointer data)
3984 {
3985 url_fetch_connect_cb(data, -1, "");
3986 return FALSE;
3987 }
3988
3982 PurpleUtilFetchUrlData * 3989 PurpleUtilFetchUrlData *
3983 purple_util_fetch_url_request_len(const char *url, gboolean full, 3990 purple_util_fetch_url_request_len(const char *url, gboolean full,
3984 const char *user_agent, gboolean http11, 3991 const char *user_agent, gboolean http11,
3985 const char *request, gboolean include_headers, gssize max_len, 3992 const char *request, gboolean include_headers, gssize max_len,
3986 PurpleUtilFetchUrlCallback callback, void *user_data) 3993 PurpleUtilFetchUrlCallback callback, void *user_data)
4014 gfud->website.address, gfud->website.port, 4021 gfud->website.address, gfud->website.port,
4015 url_fetch_connect_cb, gfud); 4022 url_fetch_connect_cb, gfud);
4016 4023
4017 if (gfud->connect_data == NULL) 4024 if (gfud->connect_data == NULL)
4018 { 4025 {
4019 purple_util_fetch_url_error(gfud, _("Unable to connect to %s"), 4026 /* Trigger the connect_cb asynchronously. */
4020 gfud->website.address); 4027 purple_timeout_add(10, url_fetch_connect_failed, gfud);
4021 return NULL;
4022 } 4028 }
4023 4029
4024 return gfud; 4030 return gfud;
4025 } 4031 }
4026 4032