diff src/dialogs.c @ 79:bfdc427b936d

[gaim-migrate @ 89] I'll save time and just post the email :-) Summary of changes: * Misc malloc/free cleanups, use g_malloc more places and other small stuff (e.g. lineardata not being freed in the error case in sound.c) * Misc signed/unsigned cleanups (use size_t more often) * read() can return -1 at any point, check return values more rigorously (read_rv variables used for this) * In can_play_audio, stat requires a pointer to an allocated stat_buf (the address of an automatic variable) * escape_text needs a buffer at least 4 times the size of the text being passed in (not 2 times); I can force core dumps with lots of newlines otherwise * There's a debug statement in netscape_command (browser.c) that was printf("Hello%d\n"); with no int for the %d; I threw in a getppid(), but the statement should probably come out eventually. Thanks, G Sumner Hayes! committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 05 Apr 2000 05:34:08 +0000
parents 03b65653798b
children 51943f1a97a0
line wrap: on
line diff
--- a/src/dialogs.c	Fri Mar 31 20:22:12 2000 +0000
+++ b/src/dialogs.c	Wed Apr 05 05:34:08 2000 +0000
@@ -895,7 +895,7 @@
 		
 	save_prefs();
 
-        buf = g_malloc(strlen(current_user->user_info) * 2);
+        buf = g_malloc(strlen(current_user->user_info) * 4);
         g_snprintf(buf, strlen(current_user->user_info) * 2, "%s", current_user->user_info);
         escape_text(buf);
         serv_set_info(buf);
@@ -2158,6 +2158,7 @@
 	char *buf;
 	char *header;
 	int hdrlen;
+	int read_rv;
 	char bmagic[5];
 	struct sockaddr_in sin;
 	int rcv;
@@ -2198,6 +2199,7 @@
 	ft->fd = socket(AF_INET, SOCK_STREAM, 0);
 	
 	if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) {
+	        g_free(buf);
 		return;
 		/*cancel */
 	}
@@ -2205,7 +2207,13 @@
 	rcv = 0;
 	header = g_malloc(6);
 	while (rcv != 6) {
-		rcv += read(ft->fd, header + rcv, 6 - rcv);
+		read_rv = read(ft->fd, header + rcv, 6 - rcv);
+		if(read_rv < 0) {
+			g_free(header);
+			g_free(buf);
+			return;
+		}
+		rcv += read_rv;
 		while(gtk_events_pending())
 			gtk_main_iteration();
 	}
@@ -2221,7 +2229,13 @@
 	rcv = 0;
 
 	while (rcv != hdrlen) {
-		rcv += read(ft->fd, header + rcv, hdrlen - rcv);
+		read_rv = read(ft->fd, header + rcv, hdrlen - rcv);
+		if(read_rv < 0) {
+			g_free(header);
+			g_free(buf);
+			return;
+		}
+		rcv += read_rv;
 		while(gtk_events_pending())
 			gtk_main_iteration();
 	}