Author: turnstep
Date: Wed Feb 23 13:32:32 2011
New Revision: 14720
Modified:
DBD-Pg/trunk/Changes
DBD-Pg/trunk/dbdimp.c
Log:
Fix memory leak with ParamValues. [Martin J. Evans] (CPAN bug #60863)
Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes (original)
+++ DBD-Pg/trunk/Changes Wed Feb 23 13:32:32 2011
@@ -2,6 +2,7 @@
2.18.0
+ - Fix memory leak with ParamValues. [Martin J. Evans] (CPAN bug #60863)
- New cancel() method per DBI spec. [Eric Simon] (CPAN bug #63516)
- New method for handling UTF8: partially deprecate pg_enable_utf8.
(still in progress)
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Wed Feb 23 13:32:32 2011
@@ -973,18 +973,22 @@
ph_t *currph;
int i;
for (i=0,currph=imp_sth->ph; NULL != currph;
currph=currph->nextph,i++) {
+ SV *key, *val;
+ key = (3==imp_sth->placeholder_type ?
newSVpv(currph->fooname,0) : newSViv(i+1));
+
if (NULL == currph->value) {
- (void)hv_store_ent
- (pvhv,
- (3==imp_sth->placeholder_type
? newSVpv(currph->fooname,0) : newSViv(i+1)),
- newSV(0), 0);
+ val = newSV(0);
+ if (!hv_store_ent(pvhv, key, val, 0)) {
+ SvREFCNT_dec(val) ;
+ }
}
else {
- (void)hv_store_ent
- (pvhv,
- (3==imp_sth->placeholder_type
? newSVpv(currph->fooname,0) : newSViv(i+1)),
- newSVpv(currph->value,0),0);
+ val = newSVpv(currph->value,0);
+ if (!hv_store_ent(pvhv, key, val, 0)) {
+ SvREFCNT_dec(val) ;
+ }
}
+ SvREFCNT_dec(key) ;
}
retsv = newRV_noinc((SV*)pvhv);
}
@@ -1037,7 +1041,7 @@
if (retsv != Nullsv) {
if (TEND) TRC(DBILOGFP, "%sEnd dbd_st_FETCH_attrib\n", THEADER);
- return retsv;
+ return sv_2mortal(retsv);
}
if (! imp_sth->result) {