changeset 23669:7eeb81cbbcae

take an extra reference to PurpleXfer so we can check whether the whole thing went away. I haven't tested this because it's late, but it shouldn't break things or at least shouldn't make things worse. (Michal Marek tested this and said it works, so I am porting this to msnp9 too)
author Ka-Hing Cheung <khc@hxbc.us>
date Thu, 07 Aug 2008 19:47:23 +0000
parents 76d03e424f82
children e8f75e750260
files libpurple/protocols/msnp9/slpcall.c libpurple/protocols/msnp9/slpcall.h libpurple/protocols/msnp9/slplink.c
diffstat 3 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msnp9/slpcall.c	Thu Aug 07 19:36:12 2008 +0000
+++ b/libpurple/protocols/msnp9/slpcall.c	Thu Aug 07 19:47:23 2008 +0000
@@ -120,8 +120,10 @@
 	if (slpcall->end_cb != NULL)
 		slpcall->end_cb(slpcall, session);
 
-	if (slpcall->xfer != NULL)
+	if (slpcall->xfer != NULL) {
+		slpcall->xfer->data = NULL;
 		purple_xfer_unref(slpcall->xfer);
+	}
 
 	g_free(slpcall);
 }
--- a/libpurple/protocols/msnp9/slpcall.h	Thu Aug 07 19:36:12 2008 +0000
+++ b/libpurple/protocols/msnp9/slpcall.h	Thu Aug 07 19:47:23 2008 +0000
@@ -25,6 +25,7 @@
 #define _MSN_SLPCALL_H_
 
 #include "internal.h"
+#include "ft.h"
 
 typedef struct _MsnSlpCall MsnSlpCall;
 
@@ -71,7 +72,7 @@
 	/* Can be checksum, or smile */
 	char *data_info;
 
-	void *xfer;
+	PurpleXfer *xfer;
 
 	MsnSlpCb cb;
 	void (*end_cb)(MsnSlpCall *slpcall, MsnSession *session);
--- a/libpurple/protocols/msnp9/slplink.c	Thu Aug 07 19:36:12 2008 +0000
+++ b/libpurple/protocols/msnp9/slplink.c	Thu Aug 07 19:47:23 2008 +0000
@@ -560,10 +560,17 @@
 
 					if (xfer != NULL)
 					{
-						purple_xfer_start(slpmsg->slpcall->xfer,
-							0, NULL, 0);
-						slpmsg->fp = ((PurpleXfer *)slpmsg->slpcall->xfer)->dest_fp;
-						xfer->dest_fp = NULL; /* Disable double fclose() */
+						purple_xfer_ref(xfer);
+						purple_xfer_start(xfer,	0, NULL, 0);
+
+						if (xfer->data == NULL) {
+							purple_xfer_unref(xfer);
+							return;
+						} else {
+							purple_xfer_unref(xfer);
+							slpmsg->fp = xfer->dest_fp;
+							xfer->dest_fp = NULL; /* Disable double fclose() */
+						}
 					}
 				}
 			}