Avoid crashing on unsuccessful send.

This commit is contained in:
Ferenc Wagner 2004-08-18 20:56:00 +00:00 committed by Alexandre Julliard
parent b6abcb51a8
commit ae1238b4b0

View file

@ -107,7 +107,7 @@ send_file (const char *name)
SOCKET s; SOCKET s;
FILE *f; FILE *f;
#define BUFLEN 8192 #define BUFLEN 8192
unsigned char *buffer; unsigned char buffer[BUFLEN+1];
size_t bytes_read, total, filesize; size_t bytes_read, total, filesize;
char *str; char *str;
int ret; int ret;
@ -127,7 +127,6 @@ send_file (const char *name)
"Upload File\r\n" "Upload File\r\n"
"--" SEP "--\r\n"; "--" SEP "--\r\n";
buffer = xmalloc (BUFLEN + 1);
s = open_http ("test.winehq.org"); s = open_http ("test.winehq.org");
if (s == INVALID_SOCKET) return 1; if (s == INVALID_SOCKET) return 1;
@ -209,17 +208,16 @@ send_file (const char *name)
if (ret) { if (ret) {
buffer[total] = 0; buffer[total] = 0;
str = strstr (buffer, "\r\n\r\n"); str = strstr (buffer, "\r\n\r\n");
if (str) buffer = str + 4; if (!str) str = buffer;
else str = str + 4;
report (R_ERROR, "Can't submit logfile '%s'. " report (R_ERROR, "Can't submit logfile '%s'. "
"Server response: %s", name, buffer); "Server response: %s", name, str);
} }
free (buffer);
return ret; return ret;
abort2: abort2:
fclose (f); fclose (f);
abort1: abort1:
close_http (s); close_http (s);
free (buffer);
return 1; return 1;
} }