summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorDoug MacEachern <dougm@covalent.net>2001-08-02 11:15:22 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2001-08-03 12:08:59 +0000
commitbc0a45ed05a5ed25882d9d65d5140ab818bd1fbf (patch)
tree3b76a426cef154aab715e5556bc140a4d965ce7c /perl.c
parent4beac62f32147d4a37c16a9084d501a03d4cf981 (diff)
downloadperl-bc0a45ed05a5ed25882d9d65d5140ab818bd1fbf.tar.gz
[patch] plug PL_origargv leak
Message-ID: <Pine.LNX.4.21.0108021813380.8991-100000@mako.covalent.net> p4raw-id: //depot/perl@11559
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/perl.c b/perl.c
index c5d33138d1..e6d6f5f28b 100644
--- a/perl.c
+++ b/perl.c
@@ -499,6 +499,11 @@ perl_destruct(pTHXx)
PL_e_script = Nullsv;
}
+ while (--PL_origargc >= 0) {
+ Safefree(PL_origargv[PL_origargc]);
+ }
+ Safefree(PL_origargv);
+
/* magical thingies */
SvREFCNT_dec(PL_ofs_sv); /* $, */
@@ -895,8 +900,21 @@ setuid perl scripts securely.\n");
("__environ", (unsigned long *) &environ_pointer, NULL);
#endif /* environ */
- PL_origargv = argv;
PL_origargc = argc;
+ {
+ /* we copy rather than point to argv
+ * since perl_clone will copy and perl_destruct
+ * has no way of knowing if we've made a copy or
+ * just point to argv
+ */
+ int i = PL_origargc;
+ New(0, PL_origargv, i+1, char*);
+ PL_origargv[i] = '\0';
+ while (i-- > 0) {
+ PL_origargv[i] = savepv(argv[i]);
+ }
+ }
+
#ifdef USE_ENVIRON_ARRAY
PL_origenviron = environ;
#endif