[libvirt] [perl-Sys-Virt][PATCH] de-mortalize the return value from hv_delete

Guannan Ren gren at redhat.com
Wed Feb 22 18:14:17 UTC 2012


   when calling block_stats() like $dom->block_stats(), it will reprot errors:

   Attempt to free unreferenced scalar: SV 0x2598498, Perl interpreter: 0x11a0010.
   Attempt to free unreferenced scalar: SV 0x258c498, Perl interpreter: 0x11a0010.
   This patch fix it.
---
 Virt.xs |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/Virt.xs b/Virt.xs
index e5d8438..9ef9715 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -3358,6 +3358,7 @@ block_stats(dom, path, flags=0)
                   field = "flush_reqs";
               if (field) {
                   SV *val = hv_delete(RETVAL, params[i].field, strlen(params[i].field), 0);
+                  SvREFCNT_inc(val);
                   (void)hv_store(RETVAL, field, strlen(field), val, 0);
               }
           }
-- 
1.7.1




More information about the libvir-list mailing list