From e6486761b694551ddb2c7ae9c87262c9a84f58fe Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 5 Mar 2015 10:48:41 +0000 Subject: [PATCH] Fix crash in inputline. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12197 d7cf8633-e32d-0410-b094-e92efae38249 --- keys.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/keys.c b/keys.c index 32648560..62db1675 100644 --- a/keys.c +++ b/keys.c @@ -1189,9 +1189,17 @@ Key_Console (int key, int unicode) // can't use strcpy to move string to right len++; //memmove(&key_line[key_linepos + u8_bytelen(key_line + key_linepos, 1)], &key_line[key_linepos], len); + if (key_linepos + blen + len >= MAX_INPUTLINE) + return; memmove(&key_line[key_linepos + blen], &key_line[key_linepos], len); } + // FIXME: This is not proper overwriting with utf8. + if (key_linepos + blen >= MAX_INPUTLINE) + return; memcpy(key_line + key_linepos, buf, blen); + if (blen > len) + key_line[key_linepos + blen] = 0; + // END OF FIXME key_linepos += blen; //key_linepos += u8_fromchar(unicode, key_line + key_linepos, sizeof(key_line) - key_linepos - 1); //key_line[key_linepos] = ascii; -- 2.39.2