comparison 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
comparison
equal deleted inserted replaced
78:66c5a24b62ec 79:bfdc427b936d
893 893
894 g_snprintf(current_user->user_info, sizeof(current_user->user_info), "%s", junk); 894 g_snprintf(current_user->user_info, sizeof(current_user->user_info), "%s", junk);
895 895
896 save_prefs(); 896 save_prefs();
897 897
898 buf = g_malloc(strlen(current_user->user_info) * 2); 898 buf = g_malloc(strlen(current_user->user_info) * 4);
899 g_snprintf(buf, strlen(current_user->user_info) * 2, "%s", current_user->user_info); 899 g_snprintf(buf, strlen(current_user->user_info) * 2, "%s", current_user->user_info);
900 escape_text(buf); 900 escape_text(buf);
901 serv_set_info(buf); 901 serv_set_info(buf);
902 g_free(buf); 902 g_free(buf);
903 g_free(junk); 903 g_free(junk);
2156 char *send = g_malloc(256); 2156 char *send = g_malloc(256);
2157 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window)); 2157 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window));
2158 char *buf; 2158 char *buf;
2159 char *header; 2159 char *header;
2160 int hdrlen; 2160 int hdrlen;
2161 int read_rv;
2161 char bmagic[5]; 2162 char bmagic[5];
2162 struct sockaddr_in sin; 2163 struct sockaddr_in sin;
2163 int rcv; 2164 int rcv;
2164 gint hdrtype, encrypt, compress, totfiles, filesleft; 2165 gint hdrtype, encrypt, compress, totfiles, filesleft;
2165 gint totparts, partsleft, totsize, size, modtime, checksum; 2166 gint totparts, partsleft, totsize, size, modtime, checksum;
2196 sin.sin_port = htons(ft->port); 2197 sin.sin_port = htons(ft->port);
2197 2198
2198 ft->fd = socket(AF_INET, SOCK_STREAM, 0); 2199 ft->fd = socket(AF_INET, SOCK_STREAM, 0);
2199 2200
2200 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) { 2201 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) {
2202 g_free(buf);
2201 return; 2203 return;
2202 /*cancel */ 2204 /*cancel */
2203 } 2205 }
2204 2206
2205 rcv = 0; 2207 rcv = 0;
2206 header = g_malloc(6); 2208 header = g_malloc(6);
2207 while (rcv != 6) { 2209 while (rcv != 6) {
2208 rcv += read(ft->fd, header + rcv, 6 - rcv); 2210 read_rv = read(ft->fd, header + rcv, 6 - rcv);
2211 if(read_rv < 0) {
2212 g_free(header);
2213 g_free(buf);
2214 return;
2215 }
2216 rcv += read_rv;
2209 while(gtk_events_pending()) 2217 while(gtk_events_pending())
2210 gtk_main_iteration(); 2218 gtk_main_iteration();
2211 } 2219 }
2212 2220
2213 strncpy(bmagic, header, 4); 2221 strncpy(bmagic, header, 4);
2219 header = g_malloc(hdrlen+1); 2227 header = g_malloc(hdrlen+1);
2220 2228
2221 rcv = 0; 2229 rcv = 0;
2222 2230
2223 while (rcv != hdrlen) { 2231 while (rcv != hdrlen) {
2224 rcv += read(ft->fd, header + rcv, hdrlen - rcv); 2232 read_rv = read(ft->fd, header + rcv, hdrlen - rcv);
2233 if(read_rv < 0) {
2234 g_free(header);
2235 g_free(buf);
2236 return;
2237 }
2238 rcv += read_rv;
2225 while(gtk_events_pending()) 2239 while(gtk_events_pending())
2226 gtk_main_iteration(); 2240 gtk_main_iteration();
2227 } 2241 }
2228 2242
2229 header[hdrlen] = 0; 2243 header[hdrlen] = 0;