diff mbox

[v2,2/5] libqos: Allow calling guest_free on NULL pointer

Message ID 1429875320-410-3-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng April 24, 2015, 11:35 a.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/libqos/malloc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

John Snow April 24, 2015, 8:01 p.m. UTC | #1
On 04/24/2015 07:35 AM, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>   tests/libqos/malloc.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c
> index 67f3190..c15be89 100644
> --- a/tests/libqos/malloc.c
> +++ b/tests/libqos/malloc.c
> @@ -283,6 +283,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);
>

Reviewed-by: John Snow <jsnow@redhat.com>
diff mbox

Patch

diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c
index 67f3190..c15be89 100644
--- a/tests/libqos/malloc.c
+++ b/tests/libqos/malloc.c
@@ -283,6 +283,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);