diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-06 02:59:09 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-06 02:59:09 +0000 |
commit | 6c4ab083df0a08a25e458d0861e2ec7909cdb03b (patch) | |
tree | 366d1e588243a1ee835b20f231a4fb92d1836312 | |
parent | 1ee082b7cc0745c3a220deae68a0a3cc2ac5bd4b (diff) | |
download | perl-6c4ab083df0a08a25e458d0861e2ec7909cdb03b.tar.gz |
fix small memleak on -e, don't try to find_script() when e_script
p4raw-id: //depot/perl@1331
-rw-r--r-- | perl.c | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -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 = ""; |