qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/3] tests/migration: mem leak fix


From: maozy
Subject: Re: [Qemu-devel] [PATCH 1/3] tests/migration: mem leak fix
Date: Wed, 11 Sep 2019 09:35:18 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0


On 9/11/19 2:52 AM, Alex Bennée wrote:
Mao Zhongyi <address@hidden> writes:

Cc: address@hidden
Cc: address@hidden
Cc: address@hidden

Signed-off-by: Mao Zhongyi <address@hidden>
---
  tests/migration/stress.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index d9aa4afe92..e6c9a6b243 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -181,6 +181,8 @@ static int stressone(unsigned long long ramsizeMB)
      if (!ram) {
          fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: 
%s\n",
                  argv0, gettid(), ramsizeMB, strerror(errno));
+        if (data)
+            free(data);
I wonder if it's worth using the glib macros here so:

   g_autofree char *data = g_malloc(PAGE_SIZE);

and the same for ram. You can then drop the frees.

I thins it's ok, which is also recommended in CODING_STYLE.rst.

Thx
    Mao
          return -1;
      }
      if (!data) {

--
Alex Bennée






reply via email to

[Prev in Thread] Current Thread [Next in Thread]