diff src/protocols/oscar/oscar.c @ 9070:f13172eed3ad

[gaim-migrate @ 9846] This fixes what is hopefully the last common direct connect segfault. Basicly, we were memcpying cookies, and one was null. This was because our get the cookie function was returning null, because it checked if the conn was a direct im conn and it wasn't. It was a listening conn instead. So this adds NULL checks, and makes the get cookie function do less sanity checking, since it was failing some valid cases. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 26 May 2004 04:55:10 +0000
parents cde9fb3546ed
children cefe59828f90
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Wed May 26 03:28:36 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Wed May 26 04:55:10 2004 +0000
@@ -3141,9 +3141,16 @@
 }
 
 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
-	GaimConnection *gc = sess->aux_data;
-	OscarData *od = gc->proto_data;
-	const char *username = gaim_account_get_username(gaim_connection_get_account(gc));
+	GaimConnection *gc;
+	OscarData *od;
+	const char *username;
+
+	g_return_val_if_fail(sess != NULL, 0);
+	g_return_val_if_fail(sess->aux_data != NULL, 0);
+
+	gc = sess->aux_data;
+	od = gc->proto_data;
+	username = gaim_account_get_username(gaim_connection_get_account(gc));
 
 	if (!args)
 		return 0;
@@ -3283,7 +3290,9 @@
 		 * and then ask them to connect to us. */
 		snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190);
 		memcpy(d->cookie, args->cookie, 8);
-		if (dim && !dim->connected && (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) {
+		if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie &&
+		    (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) {
+
 			oscar_direct_im_destroy(od, dim);
 			d->donttryagain = TRUE;
 			accept_direct_im_request(d);
@@ -3757,7 +3766,7 @@
 			struct oscar_direct_im *dim;
 
 			gaim_debug_info("oscar",
-					   "AAA - Other user declined some sort of direct"
+					   "AAA - Other user declined some sort of direct "
 					   "connect attempt (automaticly?)\n");
 			if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie)))
 				gaim_xfer_cancel_remote(xfer);