Commit d5c745e4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

widl: Don't use fixed size buffer in ctl2_encode_string.

parent 908c2bec
...@@ -342,11 +342,14 @@ static int ctl2_encode_string( ...@@ -342,11 +342,14 @@ static int ctl2_encode_string(
const char *string, /* [I] The string to encode. */ const char *string, /* [I] The string to encode. */
char **result) /* [O] A pointer to a pointer to receive the encoded string. */ char **result) /* [O] A pointer to a pointer to receive the encoded string. */
{ {
int length; char *converted_string;
static char converted_string[0x104]; size_t length, size;
int offset; int offset;
length = strlen(string); length = strlen(string);
size = (length + 5) & ~3;
if (length < 3) size += 4;
converted_string = xmalloc(size);
memcpy(converted_string + 2, string, length); memcpy(converted_string + 2, string, length);
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -365,8 +368,7 @@ static int ctl2_encode_string( ...@@ -365,8 +368,7 @@ static int ctl2_encode_string(
for (offset = (4 - (length + 2)) & 3; offset; offset--) converted_string[length + offset + 1] = 0x57; for (offset = (4 - (length + 2)) & 3; offset; offset--) converted_string[length + offset + 1] = 0x57;
*result = converted_string; *result = converted_string;
return size;
return (length + 5) & ~3;
} }
/**************************************************************************** /****************************************************************************
...@@ -604,6 +606,7 @@ static int ctl2_alloc_string( ...@@ -604,6 +606,7 @@ static int ctl2_alloc_string(
string_space = typelib->typelib_segment_data[MSFT_SEG_STRING] + offset; string_space = typelib->typelib_segment_data[MSFT_SEG_STRING] + offset;
memcpy(string_space, encoded_string, length); memcpy(string_space, encoded_string, length);
free(encoded_string);
return offset; return offset;
} }
...@@ -684,6 +687,7 @@ static int alloc_importfile( ...@@ -684,6 +687,7 @@ static int alloc_importfile(
importfile->lcid = typelib->typelib_header.lcid2; importfile->lcid = typelib->typelib_header.lcid2;
importfile->version = major_version | (minor_version << 16); importfile->version = major_version | (minor_version << 16);
memcpy(&importfile->filename, encoded_string, length); memcpy(&importfile->filename, encoded_string, length);
free(encoded_string);
return offset; return offset;
} }
......
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