• A
    virsh: fix memory leak in cmdVolPath code · 1768bf63
    Alex Jia 提交于
    * tools/virsh.c: avoid memory leak in cmdVolPath.
    * src/libvirt.c: Add doc for virStorageVolGetPath to tell one
      must free() the returned path after use.
    
    * how to reproduce?
    
    % dd if=/dev/zero of=/var/lib/libvirt/images/foo.img count=1 bs=10M
    % virsh pool-refresh default
    % valgrind -v --leak-check=full virsh vol-path --vol \
    /var/lib/libvirt/images/foo.img
    
    * actual results:
    
    Detected in valgrind run:
    
    ==16436== 32 bytes in 1 blocks are definitely lost in loss record 7 of 22
    ==16436==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
    ==16436==    by 0x386A314B3D: xdr_string (in /lib64/libc-2.12.so)
    ==16436==    by 0x3DF8CD770D: xdr_remote_nonnull_string (remote_protocol.c:3
    ==16436==    by 0x3DF8CD7EC8: xdr_remote_storage_vol_get_path_ret
    % virsh pool-refresh default
    % valgrind -v --leak-check=full virsh vol-path --vol \
    /var/lib/libvirt/images/foo.img
    Signed-off-by: NAlex Jia <ajia@redhat.com>
    1768bf63
virsh.c 425.0 KB