From ae1238b4b05479e9e658cecb04616f3523542236 Mon Sep 17 00:00:00 2001 From: Ferenc Wagner Date: Wed, 18 Aug 2004 20:56:00 +0000 Subject: [PATCH] Avoid crashing on unsuccessful send. --- programs/winetest/send.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/programs/winetest/send.c b/programs/winetest/send.c index 6cd2e9fcc82..a3a87875949 100644 --- a/programs/winetest/send.c +++ b/programs/winetest/send.c @@ -107,7 +107,7 @@ send_file (const char *name) SOCKET s; FILE *f; #define BUFLEN 8192 - unsigned char *buffer; + unsigned char buffer[BUFLEN+1]; size_t bytes_read, total, filesize; char *str; int ret; @@ -127,7 +127,6 @@ send_file (const char *name) "Upload File\r\n" "--" SEP "--\r\n"; - buffer = xmalloc (BUFLEN + 1); s = open_http ("test.winehq.org"); if (s == INVALID_SOCKET) return 1; @@ -209,17 +208,16 @@ send_file (const char *name) if (ret) { buffer[total] = 0; 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'. " - "Server response: %s", name, buffer); + "Server response: %s", name, str); } - free (buffer); return ret; abort2: fclose (f); abort1: close_http (s); - free (buffer); return 1; }