[libvirt] [PATCH 1/3] qemucaps2xmltest: Don't leak @binary

Peter Krempa pkrempa at redhat.com
Tue Apr 23 10:37:04 UTC 2019


On Tue, Apr 23, 2019 at 09:39:31 +0200, Michal Privoznik wrote:
> There's no need to keep @binary around.
> virQEMUCapsInitGuestFromBinary() duplicates the string anyway.
> 
>  1,002 bytes in 36 blocks are definitely lost in loss record 54 of 59
>     at 0x483579F: malloc (vg_replace_malloc.c:299)
>     by 0x796B1C7: vasprintf (vasprintf.c:73)
>     by 0x4C3F2C6: virVasprintfInternal (virstring.c:740)
>     by 0x4C3F3DC: virAsprintfInternal (virstring.c:761)
>     by 0x13AFC9: testGetCaps (qemucaps2xmltest.c:105)
>     by 0x13B200: testQemuCapsXML (qemucaps2xmltest.c:157)
>     by 0x13B642: virTestRun (testutils.c:174)
>     by 0x13B366: doCapsTest (qemucaps2xmltest.c:191)
>     by 0x13FF2B: testQemuCapsIterate (testutilsqemu.c:941)
>     by 0x13B427: mymain (qemucaps2xmltest.c:215)
>     by 0x13D706: virTestMain (testutils.c:1096)
>     by 0x13B489: main (qemucaps2xmltest.c:221)

Caused by 562990849a9de255b5fefa39be3f301b1bddfa6e

> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tests/qemucaps2xmltest.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
> index d107b32221..08dc598541 100644
> --- a/tests/qemucaps2xmltest.c
> +++ b/tests/qemucaps2xmltest.c
> @@ -100,7 +100,7 @@ testGetCaps(char *capsData, const testQemuData *data)
>      virQEMUCapsPtr qemuCaps = NULL;
>      virCapsPtr caps = NULL;
>      virArch arch = virArchFromString(data->archName);
> -    char *binary = NULL;
> +    VIR_AUTOFREE(char *) binary = NULL;
>  
>      if (virAsprintf(&binary, "/usr/bin/qemu-system-%s", data->archName) < 0)
>          goto error;
> @@ -129,7 +129,6 @@ testGetCaps(char *capsData, const testQemuData *data)
>   error:
>      virObjectUnref(qemuCaps);
>      virObjectUnref(caps);
> -    VIR_FREE(binary);
>      return NULL;

ACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190423/705cec19/attachment-0001.sig>


More information about the libvir-list mailing list