summaryrefslogtreecommitdiffstats
path: root/generic/tclMain.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2005-10-23 22:01:27 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2005-10-23 22:01:27 (GMT)
commit337481bde00a01912f25ffeda6d5bd4351057c7d (patch)
treec2da79f4e5a542014dab31edea47e6bd46a22b4c /generic/tclMain.c
parent352f9db6131a948693af4acd7d5ae471c54635c2 (diff)
downloadtcl-337481bde00a01912f25ffeda6d5bd4351057c7d.zip
tcl-337481bde00a01912f25ffeda6d5bd4351057c7d.tar.gz
tcl-337481bde00a01912f25ffeda6d5bd4351057c7d.tar.bz2
* generic/tclBasic.c:
* generic/tclBinary.c: * generic/tclCmdAH.c: * generic/tclCmdIL.c: * generic/tclCmdMZ.c: * generic/tclExecute.c: * generic/tclLink.c: * generic/tclMain.c: * generic/tclProc.c: * generic/tclScan.c: * generic/tclTest.c: * generic/tclVar.c: * mac/tclMacInit.c: * unix/tclUnixInit.c: * win/tclWinInit.c: Insure that the core never calls TclPtrSetVar, Tcl_SetVar2Ex, Tcl_ObjSetVar2 or Tcl_SetObjErrorCode with a 0-ref new value. It is not possible to handle error returns correctly in that case [Bug 1334947], one has the choice of leaking the object in some cases, or else risk crashing in some others.
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r--generic/tclMain.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 1b73be6..2847bd8 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMain.c,v 1.20.2.1 2005/09/30 19:28:55 dgp Exp $
+ * RCS: @(#) $Id: tclMain.c,v 1.20.2.2 2005/10/23 22:01:30 msofer Exp $
*/
#include "tcl.h"
@@ -210,6 +210,7 @@ Tcl_Main(argc, argv, appInitProc)
Tcl_Channel inChannel, outChannel, errChannel;
Tcl_Interp *interp;
Tcl_DString appName;
+ Tcl_Obj *objPtr;
Tcl_FindExecutable(argv[0]);
@@ -241,8 +242,11 @@ Tcl_Main(argc, argv, appInitProc)
argc--;
argv++;
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
-
+ objPtr = Tcl_NewIntObj(argc);
+ Tcl_IncrRefCount(objPtr);
+ Tcl_SetVar2Ex(interp, "argc", NULL, objPtr, TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(objPtr);
+
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
Tcl_DString ds;
@@ -251,7 +255,9 @@ Tcl_Main(argc, argv, appInitProc)
Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)));
Tcl_DStringFree(&ds);
}
+ Tcl_IncrRefCount(argvPtr);
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(argvPtr);
/*
* Set the "tcl_interactive" variable.