summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-07-06 02:59:09 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-07-06 02:59:09 +0000
commit6c4ab083df0a08a25e458d0861e2ec7909cdb03b (patch)
tree366d1e588243a1ee835b20f231a4fb92d1836312 /perl.c
parent1ee082b7cc0745c3a220deae68a0a3cc2ac5bd4b (diff)
downloadperl-6c4ab083df0a08a25e458d0861e2ec7909cdb03b.tar.gz
fix small memleak on -e, don't try to find_script() when e_script
p4raw-id: //depot/perl@1331
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/perl.c b/perl.c
index 7be4185cc8..7202c87b81 100644
--- a/perl.c
+++ b/perl.c
@@ -1900,20 +1900,28 @@ open_script(char *scriptname, bool dosearch, SV *sv, int *fdscript)
dTHR;
register char *s;
- /* scriptname will be non-NULL if find_script() returns */
- scriptname = find_script(scriptname, dosearch, NULL, 1);
+ *fdscript = -1;
- if (strnEQ(scriptname, "/dev/fd/", 8) && isDIGIT(scriptname[8]) ) {
- char *s = scriptname + 8;
- *fdscript = atoi(s);
- while (isDIGIT(*s))
- s++;
- if (*s)
- scriptname = s + 1;
+ if (e_script) {
+ origfilename = savepv("-e");
}
- else
- *fdscript = -1;
- origfilename = (e_script ? savepv("-e") : scriptname);
+ else {
+ /* if find_script() returns, it returns a malloc()-ed value */
+ origfilename = scriptname = find_script(scriptname, dosearch, NULL, 1);
+
+ if (strnEQ(scriptname, "/dev/fd/", 8) && isDIGIT(scriptname[8]) ) {
+ char *s = scriptname + 8;
+ *fdscript = atoi(s);
+ while (isDIGIT(*s))
+ s++;
+ if (*s) {
+ scriptname = savepv(s + 1);
+ Safefree(origfilename);
+ origfilename = scriptname;
+ }
+ }
+ }
+
curcop->cop_filegv = gv_fetchfile(origfilename);
if (strEQ(origfilename,"-"))
scriptname = "";