pidgin: 8c0179fd: Fix some closes on invalid fds, which ca...
elb at pidgin.im
elb at pidgin.im
Sun Jul 10 09:18:56 EDT 2011
----------------------------------------------------------------------
Revision: 8c0179fd3f2768a3fa391f363be79b730aee09c8
Parent: f8a81783a13ec044b2d7d2dcdd8ad830965d1cd8
Author: florian at instantbird.org
Date: 07/10/11 09:11:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8c0179fd3f2768a3fa391f363be79b730aee09c8
Changelog:
Fix some closes on invalid fds, which can crash on Windows.
Changes against parent f8a81783a13ec044b2d7d2dcdd8ad830965d1cd8
patched libpurple/protocols/simple/simple.c
patched libpurple/upnp.c
-------------- next part --------------
============================================================
--- libpurple/protocols/simple/simple.c c6ab22d22448712f03560f71c92d48aaff8924d1
+++ libpurple/protocols/simple/simple.c 01a4f7c178ea61e4b48b5665e7870b2aaf9f48f1
@@ -1932,6 +1932,8 @@ static void simple_login(PurpleAccount *
gc->proto_data = sip = g_new0(struct simple_account_data, 1);
sip->gc = gc;
+ sip->fd = -1;
+ sip->listenfd = -1;
sip->account = account;
sip->registerexpire = 900;
sip->udp = purple_account_get_bool(account, "udp", FALSE);
============================================================
--- libpurple/upnp.c b38a01b6e579af290118b3791968b63a253edfd5
+++ libpurple/upnp.c a629e1a684cd7f7be02a011ce018d341dd32110f
@@ -535,7 +535,7 @@ purple_upnp_discover_timeout(gpointer da
dd->retry_count++;
purple_upnp_discover_send_broadcast(dd);
} else {
- if (dd->fd)
+ if (dd->fd != -1)
close(dd->fd);
control_info.status = PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER;
@@ -662,7 +662,7 @@ purple_upnp_discover(PurpleUPnPCallback
}
/* Set up the sockets */
- sock = socket(AF_INET, SOCK_DGRAM, 0);
+ dd->fd = sock = socket(AF_INET, SOCK_DGRAM, 0);
if(sock == -1) {
purple_debug_error("upnp",
"purple_upnp_discover(): Failed In sock creation\n");
@@ -672,8 +672,6 @@ purple_upnp_discover(PurpleUPnPCallback
return;
}
- dd->fd = sock;
-
/* TODO: Non-blocking! */
if((hp = gethostbyname(HTTPMU_HOST_ADDRESS)) == NULL) {
purple_debug_error("upnp",
@@ -820,7 +818,7 @@ looked_up_internal_ip_cb(gpointer data,
static void
looked_up_internal_ip_cb(gpointer data, gint source, const gchar *error_message)
{
- if (source) {
+ if (source != -1) {
strncpy(control_info.internalip,
purple_network_get_local_system_ip(source),
sizeof(control_info.internalip));
More information about the Commits
mailing list