Sophie

Sophie

distrib > Fedora > 16 > x86_64 > media > updates-src > by-pkgid > f274c9b2a9294236d8d875db42ebf634 > files > 2

perl-Text-CSV_XS-0.82-3.fc16.src.rpm

From b7623f803c1d78b565d4f7aa9b2850a09b256df5 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 3 Dec 2012 20:36:14 +1100
Subject: [PATCH 1/2] avoid producing double references on per-line AVs in
 xsParse_all()

The code used newRV(), which is an alias for newRV_inc(), hence the
line AVs each had a reference count of 2 when they were returned.

rav_free() handled this by releasing both the RV and the underlying
AV, but this is unnecessary when the AVs have the correct reference
count.
---
 CSV_XS.xs |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CSV_XS.xs b/CSV_XS.xs
index 553f7fc..09fcdef 100644
--- a/CSV_XS.xs
+++ b/CSV_XS.xs
@@ -1533,11 +1533,11 @@ static SV *cx_xsParse_all (pTHX_ SV *self, HV *hv, SV *io, SV *off, SV *len)
 	    }
 
 	if (n++ >= tail) {
-	    rav_free (av_shift (avr));
+	    SvREFCNT_dec(av_shift (avr));
 	    n--;
 	    }
 
-	av_push (avr, newRV ((SV *)row));
+	av_push (avr, newRV_noinc ((SV *)row));
 
 	if (n >= length && skip >= 0)
 	    break; /* We have enough */
@@ -1545,7 +1545,7 @@ static SV *cx_xsParse_all (pTHX_ SV *self, HV *hv, SV *io, SV *off, SV *len)
 	row = newAV ();
 	}
     while (n > length) {
-	rav_free (av_pop (avr));
+	SvREFCNT_dec(av_pop (avr));
 	n--;
 	}
 
-- 
1.7.10.4