]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix crash in inputline.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Mar 2015 10:48:41 +0000 (10:48 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 5 Mar 2015 10:48:41 +0000 (10:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12197 d7cf8633-e32d-0410-b094-e92efae38249

keys.c

diff --git a/keys.c b/keys.c
index 326485609b4e22b386212a16f2ec9e3658e40c84..62db167516af5338caa42a311852266af01c0a71 100644 (file)
--- 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;