Windows: fix buffer overrun issue when parsing language XML file

This commit is contained in:
Mounir IDRASSI 2015-05-31 08:06:39 +02:00
parent 57343ce04c
commit 550e2bcf3b

View File

@ -87,7 +87,7 @@ static char *MapNextLanguageFile ()
if (find.nFileSizeHigh != 0) return NULL;
if (LanguageFileBuffer != NULL) free (LanguageFileBuffer);
LanguageFileBuffer = malloc(find.nFileSizeLow);
LanguageFileBuffer = malloc(find.nFileSizeLow + 1);
if (LanguageFileBuffer == NULL) return NULL;
GetModuleFileNameW (NULL, f, sizeof (f) / sizeof(f[0]));
@ -116,6 +116,8 @@ static char *MapNextLanguageFile ()
return NULL;
}
LanguageFileBuffer [find.nFileSizeLow] = 0; // we have allocated (find.nFileSizeLow + 1) bytes
return LanguageFileBuffer;
}