"winetest" throws an exception after the unsuccessful send
operation
Ferenc Wagner
wferi at afavant.elte.hu
Wed Aug 18 06:33:42 CDT 2004
> Is it OK to try to free the modified "buffer" ptr? I
> thought we should preserve its value.
Yes, you are right, that code is illegal. The wonderful
thing is that it's more than half a year old, and went
unnoticed this far! Probably because the WineHQ server
never failed during that period. Amazing. I wonder what
have happened to it now.
> We can use the "str" instead of the "buffer". I've tried
> such mod and it worked fine in my case:
Yes, your patch is good. Still I recommend something more,
as I can't see why buffer should be dynamic at all. Please
check it in case I made another mistake:
Index: programs/winetest/send.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/send.c,v
retrieving revision 1.12
diff -u -r1.12 send.c
--- programs/winetest/send.c 6 Jul 2004 21:03:22 -0000 1.12
+++ programs/winetest/send.c 18 Aug 2004 11:26:02 -0000
@@ -107,7 +107,7 @@
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 @@
"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,15 @@
if (ret) {
buffer[total] = 0;
str = strstr (buffer, "\r\n\r\n");
- if (str) buffer = str + 4;
+ str = str ? str+4 : buffer;
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;
}
Thanks for the good spotting,
Feri.
More information about the wine-patches
mailing list