diff mbox

tests: test-qmp-commands: Fix double free

Message ID 20140308122706.58858d92@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino March 8, 2014, 5:27 p.m. UTC
The ret variable is freed twice, but on the second time we actually want
to free ret3 instead. Don't know why this didn't explode.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 tests/test-qmp-commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake March 10, 2014, 3:49 p.m. UTC | #1
On 03/08/2014 10:27 AM, Luiz Capitulino wrote:
> The ret variable is freed twice, but on the second time we actually want
> to free ret3 instead. Don't know why this didn't explode.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Tested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  tests/test-qmp-commands.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index 8e62c2d..554e222 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -141,7 +141,7 @@  static void test_dispatch_cmd_io(void)
 
     ret3 = qobject_to_qint(test_qmp_dispatch(req));
     assert(qint_get_int(ret3) == 66);
-    QDECREF(ret);
+    QDECREF(ret3);
 
     QDECREF(req);
 }