]> git.proxmox.com Git - qemu.git/commitdiff
monitor: fix the wrong order of releasing keys
authorAmos Kong <akong@redhat.com>
Tue, 16 Apr 2013 05:47:32 +0000 (13:47 +0800)
committerLuiz Capitulino <lcapitulino@redhat.com>
Fri, 19 Apr 2013 12:32:44 +0000 (08:32 -0400)
(qemu) sendkey ctrl_r-scroll_lock-scroll_lock

Executing this command could not let Windows guest panic, it caused by
the wrong order of releasing keys. This problem was introduced by
commit e4c8f004c55d9da3eae3e14df740238bf805b5d6.

The right release order should be starting from last item.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
ui/input.c

index 9abef0cd78e0010ded3b8e60a04b62ee3f4a93b0..ecfeb43824f164a3ad67600413dbfc6d60522173 100644 (file)
@@ -234,13 +234,11 @@ static void free_keycodes(void)
 
 static void release_keys(void *opaque)
 {
-    int i;
-
-    for (i = 0; i < keycodes_size; i++) {
-        if (keycodes[i] & 0x80) {
+    while (keycodes_size > 0) {
+        if (keycodes[--keycodes_size] & 0x80) {
             kbd_put_keycode(0xe0);
         }
-        kbd_put_keycode(keycodes[i]| 0x80);
+        kbd_put_keycode(keycodes[keycodes_size] | 0x80);
     }
 
     free_keycodes();