Fixed out of bounds read access in ED_NewString(). Also fixed the creation of an
unterminated string in some cases. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1187 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
84c13a9a5b
commit
758c4b1880
1 changed files with 3 additions and 4 deletions
|
@ -968,14 +968,13 @@ char *ED_NewString (progfuncs_t *progfuncs, char *string, int minlength)
|
|||
minlength++;
|
||||
|
||||
l = strlen(string) + 1;
|
||||
if (l < minlength)
|
||||
l = minlength;
|
||||
new = PRAddressableAlloc (progfuncs, l);
|
||||
|
||||
new = PRAddressableAlloc (progfuncs, l<minlength?minlength:l);
|
||||
new_p = new;
|
||||
|
||||
for (i=0 ; i< l ; i++)
|
||||
{
|
||||
if (string[i] == '\\' && i < l-1)
|
||||
if (string[i] == '\\' && i < l-1 && string[i+1] != 0)
|
||||
{
|
||||
i++;
|
||||
if (string[i] == 'n')
|
||||
|
|
Loading…
Reference in a new issue