diff options
author | Marcus Holland-Moritz <mhx-perl@gmx.net> | 2008-01-03 17:07:06 +0000 |
---|---|---|
committer | Marcus Holland-Moritz <mhx-perl@gmx.net> | 2008-01-03 17:07:06 +0000 |
commit | 1eb9e81d303aab0f6c2386f44bc76241948fce0f (patch) | |
tree | 58d6ec74be25782902a1e976d0c4ec8a68eb5d70 /universal.c | |
parent | 4ea5041177724167b8ebcdd1a7c30762d7639fc4 (diff) | |
download | perl-1eb9e81d303aab0f6c2386f44bc76241948fce0f.tar.gz |
Fix memory leaks in XS_PerlIO_get_layers() by mortalizing
all variables pushed on the stack. Also make sure the loop
is using mXPUSHi() and not XPUSHi().
p4raw-id: //depot/perl@32816
Diffstat (limited to 'universal.c')
-rw-r--r-- | universal.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/universal.c b/universal.c index 7fc2ad367c..b4f296bc12 100644 --- a/universal.c +++ b/universal.c @@ -961,25 +961,25 @@ XS(XS_PerlIO_get_layers) if (details) { XPUSHs(namok - ? newSVpvn(SvPVX_const(*namsvp), SvCUR(*namsvp)) + ? sv_2mortal(newSVpvn(SvPVX_const(*namsvp), SvCUR(*namsvp))) : &PL_sv_undef); XPUSHs(argok - ? newSVpvn(SvPVX_const(*argsvp), SvCUR(*argsvp)) + ? sv_2mortal(newSVpvn(SvPVX_const(*argsvp), SvCUR(*argsvp))) : &PL_sv_undef); if (flgok) - XPUSHi(SvIVX(*flgsvp)); + mXPUSHi(SvIVX(*flgsvp)); else XPUSHs(&PL_sv_undef); nitem += 3; } else { if (namok && argok) - XPUSHs(Perl_newSVpvf(aTHX_ "%"SVf"(%"SVf")", + XPUSHs(sv_2mortal(Perl_newSVpvf(aTHX_ "%"SVf"(%"SVf")", SVfARG(*namsvp), - SVfARG(*argsvp))); + SVfARG(*argsvp)))); else if (namok) - XPUSHs(Perl_newSVpvf(aTHX_ "%"SVf, - SVfARG(*namsvp))); + XPUSHs(sv_2mortal(Perl_newSVpvf(aTHX_ "%"SVf, + SVfARG(*namsvp)))); else XPUSHs(&PL_sv_undef); nitem++; @@ -987,7 +987,7 @@ XS(XS_PerlIO_get_layers) const IV flags = SvIVX(*flgsvp); if (flags & PERLIO_F_UTF8) { - XPUSHs(newSVpvs("utf8")); + XPUSHs(sv_2mortal(newSVpvs("utf8"))); nitem++; } } |