Fix resizing the string buffer.

Issue=117 TRAC #15793 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@605 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ae345807
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 604 #define BUILD_REVISION 605
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -182,12 +182,13 @@ static int AddString(StringTable *stable, const char *s) ...@@ -182,12 +182,13 @@ static int AddString(StringTable *stable, const char *s)
char *str; char *str;
len = (int) strlen(s); len = (int) strlen(s);
if (stable->nextFree + len + 1 >= stable->size) { while (stable->nextFree + len + 1 >= stable->size) {
assert(stable->size < 1000000); assert(stable->size < 1000000);
str = (char *) malloc(stable->size*2); str = (char *) malloc(stable->size*2);
memcpy(str, stable->strings, stable->size); memcpy(str, stable->strings, stable->size);
free(stable->strings); free(stable->strings);
stable->strings = str; stable->strings = str;
stable->size = stable->size*2;
} }
loc = stable->nextFree; loc = stable->nextFree;
strcpy(&stable->strings[loc], s); strcpy(&stable->strings[loc], s);
......
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