summaryrefslogtreecommitdiff
path: root/network/remmina/patches/20120505a.patch
blob: 64baac04fe680ddf2fa0df32a22d149c25e68087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From 6ee2028996ee9d8802201e95f3cec56e2b307ddb Mon Sep 17 00:00:00 2001
From: Jean-Louis Dupond <jean-louis@dupond.be>
Date: Sat, 5 May 2012 16:54:18 +0200
Subject: [PATCH] Fix crashes in some cases

---
 remmina-plugins/rdp/rdp_cliprdr.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/remmina-plugins/rdp/rdp_cliprdr.c b/remmina-plugins/rdp/rdp_cliprdr.c
index d84374e..772709c 100644
--- a/remmina-plugins/rdp/rdp_cliprdr.c
+++ b/remmina-plugins/rdp/rdp_cliprdr.c
@@ -204,7 +204,7 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 	g_printf("GetData: Requested Format: %#X\n", format);
 	rfContext* rfi = GET_DATA(gp);
 	GtkClipboard* clipboard;
-	uint8* inbuf = (uint8*)"";
+	uint8* inbuf = NULL;
 	uint8* outbuf = NULL;
 	GdkPixbuf *image = NULL;
 	
@@ -223,10 +223,18 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 	}
 	THREADS_LEAVE
 
+	/* No data received, send nothing */
+	if (inbuf == NULL && image == NULL)
+	{
+		g_printf("NO DATA RECEIVED\n");
+		*size = 0;
+		return NULL;
+	}
+
+
 	if (format == CB_FORMAT_TEXT || format == CB_FORMAT_HTML || format == CB_FORMAT_UNICODETEXT)
 	{
-		if (inbuf == NULL)
-			inbuf = (uint8*)"";
+		*size = strlen((char*)inbuf);
 		inbuf = lf2crlf(inbuf, size);
 		if (format == CB_FORMAT_TEXT)
 		{
@@ -258,12 +266,14 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 			gdk_pixbuf_save_to_buffer(image, &data, &buffersize, "png", NULL, NULL);
 			outbuf = (uint8*) xmalloc(buffersize);
 			memcpy(outbuf, data, buffersize);
+			*size = buffersize;
 		}
 		if (format == CB_FORMAT_JPEG)
 		{
 			gdk_pixbuf_save_to_buffer(image, &data, &buffersize, "jpeg", NULL, NULL);
 			outbuf = (uint8*) xmalloc(buffersize);
 			memcpy(outbuf, data, buffersize);
+			*size = buffersize;
 		}
 		if (format == CB_FORMAT_DIB)
 		{
@@ -276,9 +286,6 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 		g_object_unref(image);
 	}
 
-	if (!outbuf)
-		outbuf = (uint8*)"";
-
 	return outbuf;
 }
 
-- 
1.7.10