]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Since u8_prevbyte skips invalid chars on purpose, it can go before the ] if invalid...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Sep 2010 15:32:09 +0000 (15:32 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Sep 2010 15:32:09 +0000 (15:32 +0000)
Fix this bug by giving to u8_prevbyte the edit line without ].

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10439 d7cf8633-e32d-0410-b094-e92efae38249

keys.c

diff --git a/keys.c b/keys.c
index 18765a167e2c0c6c050dd6e915502c858ac1d654..478e8a168c9be3df832a532350054416037fe5bd 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -713,7 +713,7 @@ Key_Console (int key, int unicode)
                {
                        int             pos;
                        size_t          inchar = 0;
-                       pos = u8_prevbyte(key_line, key_linepos);
+                       pos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte
                        while (pos)
                                if(pos-1 > 0 && key_line[pos-1] == STRING_COLOR_TAG && isdigit(key_line[pos]))
                                        pos-=2;
@@ -733,7 +733,7 @@ Key_Console (int key, int unicode)
                }
                else
                {
-                       key_linepos = u8_prevbyte(key_line, key_linepos);
+                       key_linepos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte
                }
                return;
        }
@@ -743,7 +743,7 @@ Key_Console (int key, int unicode)
        {
                if (key_linepos > 1)
                {
-                       int newpos = u8_prevbyte(key_line, key_linepos);
+                       int newpos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte
                        strlcpy(key_line + newpos, key_line + key_linepos, sizeof(key_line) + 1 - key_linepos);
                        key_linepos = newpos;
                }