summaryrefslogtreecommitdiffstats
path: root/generic/tclMain.c
diff options
context:
space:
mode:
authorbch <brad.harder@gmail.com>2022-01-28 10:46:06 (GMT)
committerbch <brad.harder@gmail.com>2022-01-28 10:46:06 (GMT)
commit43b31960b76a22c951489e76a812d22fae7582e2 (patch)
treebedf6cf49ecf7203cf5e7a6e506d1607bcf33240 /generic/tclMain.c
parent60f5d30e4406df3a2d80e61d7d9972dce3293133 (diff)
downloadtcl-43b31960b76a22c951489e76a812d22fae7582e2.zip
tcl-43b31960b76a22c951489e76a812d22fae7582e2.tar.gz
tcl-43b31960b76a22c951489e76a812d22fae7582e2.tar.bz2
be more strict about using argv[0]
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r--generic/tclMain.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c
index c2eee13..de745bd 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -288,6 +288,7 @@ Tcl_MainEx(
* but before starting to execute commands. */
Tcl_Interp *interp)
{
+ char *progname = NULL; /* may/may-not be able to use argv[0] */
int i=0; /* argv[i] index */
Tcl_Obj *path, *resultPtr, *argvPtr, *appName;
const char *encodingName = NULL;
@@ -298,10 +299,11 @@ Tcl_MainEx(
TclpSetInitialEncodings();
if (0 < argc) {
+ progname = argv[0];
--argc; /* consume argv[0] */
++i;
}
- TclpFindExecutable((const char *)argv[0]); /* nb: this could be NULL
+ TclpFindExecutable ((const char *)progname); /* nb: this could be NULL
* w/ (eg) a malformed
* execve() */
@@ -343,7 +345,7 @@ Tcl_MainEx(
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
- appName = NewNativeObj(argv[0]); // nb: argv is _not_ advanced here...
+ appName = NewNativeObj(progname);
} else {
appName = path;
}