[Libguestfs] [PATCH] inspector: --xpath: Copy node to new document (RHBZ#1281577).

Pino Toscano ptoscano at redhat.com
Fri Nov 13 10:15:26 UTC 2015


On Thursday 12 November 2015 22:43:06 Richard W.M. Jones wrote:
> 'virt-inspector --xpath' can segfault.
> 
> When run under valgrind, it shows this error:
> 
> ==2254== Invalid free() / delete / delete[] / realloc()
> ==2254==    at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==2254==    by 0x53BA198: xmlFreeNodeList (tree.c:3690)
> ==2254==    by 0x53B9F65: xmlFreeDoc (tree.c:1247)
> ==2254==    by 0x405BFA: do_xpath (inspector.c:808)
> ==2254==    by 0x405BFA: main (inspector.c:250)
> ==2254==  Address 0x1030a037 is 311 bytes inside a block of size 1,048 alloc'd
> ==2254==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==2254==    by 0x545DE86: xmlDictAddString.isra.0 (dict.c:270)
> ==2254==    by 0x545E961: xmlDictLookup (dict.c:923)
> ==2254==    by 0x539C6DC: xmlDetectSAX2 (parser.c:1067)
> ==2254==    by 0x53B0B92: xmlParseDocument (parser.c:10725)
> ==2254==    by 0x53B1276: xmlDoRead (parser.c:15295)
> ==2254==    by 0x40587D: do_xpath (inspector.c:772)
> ==2254==    by 0x40587D: main (inspector.c:250)
> 
> The cause appears to be that when copying the matching node(s) found
> by the xpath expression, we have to copy them into the new document
> (using xmlDocCopyNode instead of xmlCopyNode).
> 
> This bug has existed since this functionality was originally added in
> commit d1ee71782ace98a11c5aabaf1f9fd5f601e08367.
> ---

LGTM.

Thanks,
-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20151113/17ff4cce/attachment.sig>


More information about the Libguestfs mailing list