]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
i9e: Replace assertion with warning.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 18 Mar 2016 22:44:15 +0000 (23:44 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 1 Apr 2016 23:40:15 +0000 (01:40 +0200)
The assertion in dispatch_key() can easily be triggered with keys
that map to multi-byte sequences. This patch prevents para_play from
aborting when such a key is pressed. It now issues a warning message,
but no longer aborts.

interactive.c

index a568d3c5c82fb065eaaff9c86aeed02ff5310094..b72148cc41df54e79f0da53bd4853ba979674a0c 100644 (file)
@@ -437,6 +437,9 @@ static int dispatch_key(__a_unused int count, __a_unused int key)
 {
        int i, ret;
 
 {
        int i, ret;
 
+again:
+       if (i9ep->key_sequence_length == 0)
+               return 0;
        for (i = i9ep->num_key_bindings - 1; i >= 0; i--) {
                if (strcmp(i9ep->key_sequence, i9ep->ici->bound_keyseqs[i]))
                        continue;
        for (i = i9ep->num_key_bindings - 1; i >= 0; i--) {
                if (strcmp(i9ep->key_sequence, i9ep->ici->bound_keyseqs[i]))
                        continue;
@@ -445,7 +448,15 @@ static int dispatch_key(__a_unused int count, __a_unused int key)
                ret = i9ep->ici->key_handler(i);
                return ret < 0? ret : 0;
        }
                ret = i9ep->ici->key_handler(i);
                return ret < 0? ret : 0;
        }
-       assert(0);
+       PARA_WARNING_LOG("ignoring key %d\n", i9ep->key_sequence[0]);
+       /*
+        * We received an undefined key sequence. Throw away the first byte,
+        * and try to parse the remainder.
+        */
+       memmove(i9ep->key_sequence, i9ep->key_sequence + 1,
+               i9ep->key_sequence_length); /* move also terminating zero byte */
+       i9ep->key_sequence_length--;
+       goto again;
 }
 
 /**
 }
 
 /**