diff libpurple/ft.c @ 29832:2ab17571bf42

propagate from branch 'im.pidgin.pidgin' (head 7850267e7626c94b519fd5f1c959c79f0624d34e) to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head 3845c5c2ec11e409fd1891793e73ab3d934001f9)
author Marcus Lundblad <ml@update.uu.se>
date Sat, 24 Apr 2010 14:59:13 +0000
parents 6671b5e92c28 6797736dbe37
children 834038426c38
line wrap: on
line diff
--- a/libpurple/ft.c	Wed Mar 24 20:16:05 2010 +0000
+++ b/libpurple/ft.c	Sat Apr 24 14:59:13 2010 +0000
@@ -57,6 +57,8 @@
 		PURPLE_XFER_READY_UI   = 0x1,
 		PURPLE_XFER_READY_PRPL = 0x2,
 	} ready;
+
+	/* TODO: Should really use a PurpleCircBuffer for this. */
 	GByteArray *buffer;
 
 	gpointer thumbnail_data;		/**< thumbnail image */
@@ -1199,7 +1201,7 @@
 		}
 
 		if (priv->buffer) {
-			priv->buffer = g_byte_array_append(priv->buffer, buffer, result);
+			g_byte_array_append(priv->buffer, buffer, result);
 			g_free(buffer);
 			buffer = priv->buffer->data;
 			result = priv->buffer->len;
@@ -1209,7 +1211,10 @@
 
 		if (r == -1) {
 			purple_xfer_cancel_remote(xfer);
-			g_free(buffer);
+			if (!priv->buffer)
+				/* We don't free buffer if priv->buffer is set, because in
+				   that case buffer doesn't belong to us. */
+				g_free(buffer);
 			return;
 		} else if (r == result) {
 			/*
@@ -1227,10 +1232,10 @@
 			/*
 			 * Remove what we wrote
 			 * If we wrote the whole buffer the byte array will be empty
-			 * Otherwise we'll kee what wasn't sent for next time.
+			 * Otherwise we'll keep what wasn't sent for next time.
 			 */
 			buffer = NULL;
-			priv->buffer = g_byte_array_remove_range(priv->buffer, 0, r);
+			g_byte_array_remove_range(priv->buffer, 0, r);
 		}
 	}