libpurple/protocols/gg/lib/dcc.c

branch
release-2.x.y
changeset 37180
cf498d4b54bb
parent 35627
fd11790cc4d6
child 37181
06b74c255e95
--- a/libpurple/protocols/gg/lib/dcc.c	Fri Apr 10 13:27:57 2015 +0530
+++ b/libpurple/protocols/gg/lib/dcc.c	Sat May 09 14:54:05 2015 +0200
@@ -650,6 +650,7 @@
 		unsigned int utmp;
 		socklen_t res_size = sizeof(res);
 		char buf[1024], ack[] = "UDAG";
+		void *tmp_buf;
 
 		struct gg_dcc_file_info_packet {
 			struct gg_dcc_big_packet big;
@@ -799,11 +800,14 @@
 				h->state = GG_STATE_READING_FILE_HEADER;
 				h->chunk_size = sizeof(big_pkt);
 				h->chunk_offset = 0;
-				if (!(h->chunk_buf = malloc(sizeof(big_pkt)))) {
+				h->chunk_buf = NULL;
+				tmp_buf = malloc(sizeof(big_pkt));
+				if (!tmp_buf) {
 					gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() out of memory\n");
 					free(e);
 					return NULL;
 				}
+				h->chunk_buf = tmp_buf;
 				h->check = GG_CHECK_READ;
 				h->timeout = GG_DEFAULT_TIMEOUT;
 
@@ -1342,11 +1346,14 @@
 					h->timeout = GG_DEFAULT_TIMEOUT;
 					h->chunk_offset = 0;
 					h->chunk_size = sizeof(big_pkt);
-					if (!(h->chunk_buf = malloc(sizeof(big_pkt)))) {
+					h->chunk_buf = NULL;
+					tmp_buf = malloc(sizeof(big_pkt));
+					if (!tmp_buf) {
 						gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() out of memory\n");
 						free(e);
 						return NULL;
 					}
+					h->chunk_buf = tmp_buf;
 				} else {
 					h->state = GG_STATE_GETTING_FILE;
 					h->timeout = GG_DCC_TIMEOUT_GET;

mercurial