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>
This commit is contained in:
Bertho Stultiens 1998-11-06 10:51:40 +00:00 committed by Alexandre Julliard
parent f5e3b6995b
commit 3b7212809b
3 changed files with 15 additions and 7 deletions

View File

@ -1,4 +1,10 @@
---------------------------------------------------------------------------
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)
- Started this file

View File

@ -12,8 +12,8 @@
#include "wrctypes.h"
#endif
#define WRC_VERSION "1.0.2"
#define WRC_RELEASEDATE "(20-Jun-1998)"
#define WRC_VERSION "1.0.3"
#define WRC_RELEASEDATE "(02-Nov-1998)"
#define WRC_FULLVERSION WRC_VERSION " " WRC_RELEASEDATE
/* Only used in heavy debugging sessions */

View File

@ -208,14 +208,15 @@ void write_name_str(FILE *fp, name_id_t *nid)
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)
error("Can't write strings larger than 254 bytes");
if(res.size == 0)
internal_error(__FILE__, __LINE__, "Attempt to write empty string");
res.dataidx = 0;
res.data = (char *)xmalloc(res.size);
res.data = (char *)xmalloc(res.size + 1);
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);
write_s_res(fp, &res);
free(res.data);
@ -246,16 +247,17 @@ void write_name_str(FILE *fp, name_id_t *nid)
}
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)
error("Can't write strings larger than 65534 bytes");
if(res.size == 0)
internal_error(__FILE__, __LINE__, "Attempt to write empty string");
res.dataidx = 0;
res.data = (char *)xmalloc(res.size * 2);
((short *)res.data)[0] = (char)res.size;
res.data = (char *)xmalloc((res.size + 1) * 2);
((short *)res.data)[0] = (short)res.size;
wstrcpy((short *)(res.data+2), nid->name.s_name->str.wstr);
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);
free(res.data);
}