util: buf: Fix memory leak in virBufferEscapeN
The conversion to VIR_AUTOFREE of 'escapeList' introduced memory leak of the copied item to be escaped: ==17517== 2 bytes in 1 blocks are definitely lost in loss record 1 of 32 ==17517== at 0x483880B: malloc (vg_replace_malloc.c:309) ==17517== by 0x54D666D: strdup (in /usr/lib64/libc-2.28.so) ==17517== by 0x497663E: virStrdup (virstring.c:956) ==17517== by 0x497663E: virStrdup (virstring.c:945) ==17517== by 0x48F8853: virBufferEscapeN (virbuffer.c:707) ==17517== by 0x403C9D: testBufEscapeN (virbuftest.c:383) ==17517== by 0x405FA8: virTestRun (testutils.c:174) ==17517== by 0x403A70: mymain (virbuftest.c:517) ==17517== by 0x406BC9: virTestMain (testutils.c:1097) ==17517== by 0x5470412: (below main) (in /usr/lib64/libc-2.28.so) [...] (all other have same backtrace as it happens in a loop) Fix it by reverting all the VIR_AUTO nonsense in this function as there is exactly one place where it's handled. This effectively reverts commits: d0a92a03 96fbf6df d261ed2fSigned-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NEric Blake <eblake@redhat.com>
Showing
想要评论请 注册 或 登录