libqos: Allow calling guest_free on NULL pointer
authorFam Zheng <famz@redhat.com>
Fri, 24 Apr 2015 11:35:17 +0000 (19:35 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 17 Jun 2015 14:03:47 +0000 (16:03 +0200)
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/libqos/malloc.c

index 8276130..82b9df5 100644 (file)
@@ -285,6 +285,9 @@ uint64_t guest_alloc(QGuestAllocator *allocator, size_t size)
 
 void guest_free(QGuestAllocator *allocator, uint64_t addr)
 {
+    if (!addr) {
+        return;
+    }
     mlist_free(allocator, addr);
     if (allocator->opts & ALLOC_PARANOID) {
         mlist_check(allocator);