]> xenbits.xensource.com Git - qemu-xen-4.2-testing.git/commitdiff
qemu_timer_pending/qemu_get_timer: cope with NULL timers
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 5 Dec 2011 13:43:34 +0000 (13:43 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 5 Dec 2011 13:43:34 +0000 (13:43 +0000)
qemu_timer_pending and qemu_get_timer: don't crash if the timer passed
as an argument is NULL.

[ Fixes regression: 13b06e700528 broke save/restore on Xen. -iwj ]

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
vl.c

diff --git a/vl.c b/vl.c
index f07a6592ac84954a4ce59b1dd04d96d2c2642b64..f3b3d02ab57030b5cde4a514ca40d7d7b1447426 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1201,6 +1201,10 @@ void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time)
 int qemu_timer_pending(QEMUTimer *ts)
 {
     QEMUTimer *t;
+
+    if (ts == NULL)
+        return 0;
+
     for(t = active_timers[ts->clock->type]; t != NULL; t = t->next) {
         if (t == ts)
             return 1;
@@ -1272,6 +1276,9 @@ void qemu_get_timer(QEMUFile *f, QEMUTimer *ts)
 {
     uint64_t expire_time;
 
+    if (ts == NULL)
+        return;
+
     expire_time = qemu_get_be64(f);
     if (expire_time != -1) {
         qemu_mod_timer(ts, expire_time);