changeset 13986:8a8b4f7f7d99

[gaim-migrate @ 16556] Fix a minor case of accessing something that had been free'd in oscar, and some other minor cleanup. FYI "0" is a valid file descriptor, but it will pretty much always be STDOUT, STDERR or STDIN. But I like to check for -1 anyway, because I'm weird. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 24 Jul 2006 04:27:42 +0000
parents a7b1d2ab9cb0
children f94309c7c480
files src/protocols/oscar/flap_connection.c src/protocols/oscar/odc.c src/protocols/oscar/oscar.h src/sslconn.c
diffstat 4 files changed, 13 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/flap_connection.c	Mon Jul 24 01:03:07 2006 +0000
+++ b/src/protocols/oscar/flap_connection.c	Mon Jul 24 04:27:42 2006 +0000
@@ -205,7 +205,6 @@
 	flap_connection_destroy_rates(conn->rates);
 
 	od->oscar_connections = g_list_remove(od->oscar_connections, conn);
-	g_free(conn);
 
 	account = gaim_connection_get_account(od->gc);
 
@@ -227,12 +226,18 @@
 		else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT)
 			tmp = _("Could not establish a connection with the server.");
 		else
+			/*
+			 * We shouldn't print a message for some disconnect_reasons.
+			 * Like OSCAR_DISCONNECT_LOCAL_CLOSED.
+			 */
 			tmp = NULL;
 
 		if (tmp != NULL)
 			gaim_connection_error(od->gc, tmp);
 	}
 
+	g_free(conn);
+
 	return FALSE;
 }
 
--- a/src/protocols/oscar/odc.c	Mon Jul 24 01:03:07 2006 +0000
+++ b/src/protocols/oscar/odc.c	Mon Jul 24 04:27:42 2006 +0000
@@ -37,25 +37,15 @@
 	const gchar *tmp;
 
 	if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED)
-	{
 		tmp = _("The remote user has closed the connection.");
-	}
 	else if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_REFUSED)
-	{
 		tmp = _("The remote user has declined your request.");
-	}
 	else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION)
-	{
 		tmp = _("Lost connection with the remote user for an unknown reason.");
-	}
 	else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA)
-	{
 		tmp = _("Received invalid data on connection with remote user.");
-	}
 	else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT)
-	{
 		tmp = _("Could not establish a connection with the remote user.");
-	}
 	else
 		/*
 		 * We shouldn't print a message for some disconnect_reasons.
--- a/src/protocols/oscar/oscar.h	Mon Jul 24 01:03:07 2006 +0000
+++ b/src/protocols/oscar/oscar.h	Mon Jul 24 04:27:42 2006 +0000
@@ -287,14 +287,14 @@
 
 typedef enum
 {
-	OSCAR_DISCONNECT_DONE,
-	OSCAR_DISCONNECT_LOCAL_CLOSED,
+	OSCAR_DISCONNECT_DONE, /* not considered an error */
+	OSCAR_DISCONNECT_LOCAL_CLOSED, /* peer connections only, not considered an error */
 	OSCAR_DISCONNECT_REMOTE_CLOSED,
-	OSCAR_DISCONNECT_REMOTE_REFUSED,
+	OSCAR_DISCONNECT_REMOTE_REFUSED, /* peer connections only */
 	OSCAR_DISCONNECT_LOST_CONNECTION,
 	OSCAR_DISCONNECT_INVALID_DATA,
 	OSCAR_DISCONNECT_COULD_NOT_CONNECT,
-	OSCAR_DISCONNECT_RETRYING
+	OSCAR_DISCONNECT_RETRYING /* peer connections only */
 } OscarDisconnectReason;
 
 typedef enum
--- a/src/sslconn.c	Mon Jul 24 01:03:07 2006 +0000
+++ b/src/sslconn.c	Mon Jul 24 04:27:42 2006 +0000
@@ -137,7 +137,7 @@
 	GaimSslConnection *gsc;
 	GaimSslOps *ops;
 
-	g_return_val_if_fail(fd > 0,                  NULL);
+	g_return_val_if_fail(fd != -1,                NULL);
 	g_return_val_if_fail(func != NULL,            NULL);
 	g_return_val_if_fail(gaim_ssl_is_supported(), NULL);
 
@@ -178,12 +178,10 @@
 	if (ops != NULL && ops->close != NULL)
 		(ops->close)(gsc);
 
-	if (gsc->fd)
+	if (gsc->fd != -1)
 		close(gsc->fd);
 
-	if (gsc->host != NULL)
-		g_free(gsc->host);
-
+	g_free(gsc->host);
 	g_free(gsc);
 }