summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-07-21 00:39:17 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-07-21 00:39:17 +0000
commitda7e89ce5b5c5366c1d9d918e5037309b09415df (patch)
treeb5f011f29d3d216162a4a41e58353a6235d1b112 /perl.c
parent67ec543f8711d298466404cf8278e57f2908e040 (diff)
downloadperl-da7e89ce5b5c5366c1d9d918e5037309b09415df.tar.gz
fix small memory leak when mess_sv happens to be touched by magic
p4raw-id: //depot/perl@1585
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/perl.c b/perl.c
index bebcb02a59..df306dc0e1 100644
--- a/perl.c
+++ b/perl.c
@@ -567,6 +567,17 @@ perl_destruct(register PerlInterpreter *sv_interp)
/* As the absolutely last thing, free the non-arena SV for mess() */
if (PL_mess_sv) {
+ /* it could have accumulated taint magic */
+ if (SvTYPE(PL_mess_sv) >= SVt_PVMG) {
+ MAGIC* mg;
+ MAGIC* moremagic;
+ for (mg = SvMAGIC(PL_mess_sv); mg; mg = moremagic) {
+ moremagic = mg->mg_moremagic;
+ if (mg->mg_ptr && mg->mg_type != 'g' && mg->mg_len >= 0)
+ Safefree(mg->mg_ptr);
+ Safefree(mg);
+ }
+ }
/* we know that type >= SVt_PV */
SvOOK_off(PL_mess_sv);
Safefree(SvPVX(PL_mess_sv));