Commit 3b721280 authored by Bertho Stultiens's avatar Bertho Stultiens Committed by Alexandre Julliard

Bugfix in write_name_str() [writeres.c] where the length byte/word was

wrongly counted in the length of the string. Thanks to Ulrich Weigand <weigand@informatik.uni-erlangen.de>
parent f5e3b699
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Version 1.0.3 (02-Nov-1998)
- Bugfix in write_name_str() [writeres.c] where the length byte/word was
wrongly counted in the length of the string.
Thanks to Ulrich Weigand <weigand@informatik.uni-erlangen.de>
---------------------------------------------------------------------------
Version 1.0.2 (20-Jun-1998) Version 1.0.2 (20-Jun-1998)
- Started this file - Started this file
- Fixed a bug in filename scanning when they are double quoted. The code now - Fixed a bug in filename scanning when they are double quoted. The code now
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "wrctypes.h" #include "wrctypes.h"
#endif #endif
#define WRC_VERSION "1.0.2" #define WRC_VERSION "1.0.3"
#define WRC_RELEASEDATE "(20-Jun-1998)" #define WRC_RELEASEDATE "(02-Nov-1998)"
#define WRC_FULLVERSION WRC_VERSION " " WRC_RELEASEDATE #define WRC_FULLVERSION WRC_VERSION " " WRC_RELEASEDATE
/* Only used in heavy debugging sessions */ /* Only used in heavy debugging sessions */
......
...@@ -208,14 +208,15 @@ void write_name_str(FILE *fp, name_id_t *nid) ...@@ -208,14 +208,15 @@ void write_name_str(FILE *fp, name_id_t *nid)
if(!win32 && nid->name.s_name->type == str_char) if(!win32 && nid->name.s_name->type == str_char)
{ {
res.size = strlen(nid->name.s_name->str.cstr) + 1; res.size = strlen(nid->name.s_name->str.cstr);
if(res.size > 254) if(res.size > 254)
error("Can't write strings larger than 254 bytes"); error("Can't write strings larger than 254 bytes");
if(res.size == 0) if(res.size == 0)
internal_error(__FILE__, __LINE__, "Attempt to write empty string"); internal_error(__FILE__, __LINE__, "Attempt to write empty string");
res.dataidx = 0; res.dataidx = 0;
res.data = (char *)xmalloc(res.size); res.data = (char *)xmalloc(res.size + 1);
res.data[0] = (char)res.size; res.data[0] = (char)res.size;
res.size++; /* We need to write the lenth byte as well */
strcpy(res.data+1, nid->name.s_name->str.cstr); strcpy(res.data+1, nid->name.s_name->str.cstr);
write_s_res(fp, &res); write_s_res(fp, &res);
free(res.data); free(res.data);
...@@ -246,16 +247,17 @@ void write_name_str(FILE *fp, name_id_t *nid) ...@@ -246,16 +247,17 @@ void write_name_str(FILE *fp, name_id_t *nid)
} }
else if(win32 && nid->name.s_name->type == str_unicode) else if(win32 && nid->name.s_name->type == str_unicode)
{ {
res.size = wstrlen(nid->name.s_name->str.wstr) + 1; res.size = wstrlen(nid->name.s_name->str.wstr);
if(res.size > 65534) if(res.size > 65534)
error("Can't write strings larger than 65534 bytes"); error("Can't write strings larger than 65534 bytes");
if(res.size == 0) if(res.size == 0)
internal_error(__FILE__, __LINE__, "Attempt to write empty string"); internal_error(__FILE__, __LINE__, "Attempt to write empty string");
res.dataidx = 0; res.dataidx = 0;
res.data = (char *)xmalloc(res.size * 2); res.data = (char *)xmalloc((res.size + 1) * 2);
((short *)res.data)[0] = (char)res.size; ((short *)res.data)[0] = (short)res.size;
wstrcpy((short *)(res.data+2), nid->name.s_name->str.wstr); wstrcpy((short *)(res.data+2), nid->name.s_name->str.wstr);
res.size *= 2; /* Function writes bytes, not shorts... */ res.size *= 2; /* Function writes bytes, not shorts... */
res.size += 2; /* We need to write the length word as well */
write_s_res(fp, &res); write_s_res(fp, &res);
free(res.data); free(res.data);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment