[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-unstable] keymaps.c: fix use after free in del_key_range



commit fdb22f24bc8adb3455b771d804496e11b4570085
Author: Jan Beulich <jbeulich@xxxxxxxxxx>
Date:   Mon Jan 17 18:00:37 2011 +0000

    keymaps.c: fix use after free in del_key_range
    
    Commit 99d53fbb69d3e03be61ae10506a304a3d08d792f introduced this, and
    the compiler indirectly warned about it.
    
    The patch is only compile tested (I don't even know how to reproduce
    the original problem), but I suppose worth applying regardless.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
    Cc: Chun Yan Liu <cyliu@xxxxxxxxxx>
---
 keymaps.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/keymaps.c b/keymaps.c
index 12b83a5..d92057f 100644
--- a/keymaps.c
+++ b/keymaps.c
@@ -56,15 +56,12 @@ typedef struct {
 
 static void del_key_range(struct key_range **krp, int code) {
     struct key_range *kr;
-    struct key_range *kr_pr;
-    for (kr = *krp; kr; kr_pr = kr, kr = kr->next) {
+    while ((kr = *krp) != NULL) {
         if (code >= kr->start && code <= kr->end) {
-            if (kr == *krp)
-                *krp = kr->next;
-            else
-                kr_pr->next = kr->next;
+            *krp = kr->next;
             qemu_free(kr);
-        }
+        } else
+            krp = &kr->next;
     }
 }
 
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.