diff options
author | hobbs <hobbs@noemail.net> | 2006-03-29 01:22:48 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2006-03-29 01:22:48 (GMT) |
commit | 81190c420ed9901e7d14ddbcf2f4a7606d2eaca2 (patch) | |
tree | 09b5a80bb32b37aa3f6af3896dba28f4b2861cc2 /win | |
parent | e8332d7611b4ce31045b6e570db63461092989e0 (diff) | |
download | tcl-81190c420ed9901e7d14ddbcf2f4a7606d2eaca2.zip tcl-81190c420ed9901e7d14ddbcf2f4a7606d2eaca2.tar.gz tcl-81190c420ed9901e7d14ddbcf2f4a7606d2eaca2.tar.bz2 |
* win/tclWinPipe.c (TclpCreateProcess): change panics to Tcl
errors and do proper refcounting of noe objPtr. [bug 1194429]
FossilOrigin-Name: 79a703d1e5818660984139ce418be6b1550ae4d9
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinPipe.c | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 11a180d..1795d3a 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.63 2006/03/27 18:08:51 andreas_kupries Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.64 2006/03/29 01:22:49 hobbs Exp $ */ #include "tclWinInt.h" @@ -1173,6 +1173,10 @@ TclpCreateProcess( * The helper app should be located in the same directory as the * tcl dll. */ + Tcl_Obj *tclExePtr, *pipeDllPtr; + char *start, *end; + int i, fileExists; + Tcl_DString pipeDll; if (createFlags != 0) { startInfo.wShowWindow = SW_HIDE; @@ -1180,41 +1184,44 @@ TclpCreateProcess( createFlags = CREATE_NEW_CONSOLE; } - { - Tcl_Obj *tclExePtr, *pipeDllPtr; - int i, fileExists; - char *start,*end; - Tcl_DString pipeDll; - - Tcl_DStringInit(&pipeDll); - Tcl_DStringAppend(&pipeDll, TCL_PIPE_DLL, -1); - tclExePtr = TclGetObjNameOfExecutable(); - start = Tcl_GetStringFromObj(tclExePtr, &i); - for (end = start + (i-1); end > start; end--) { - if (*end == '/') { - break; - } - } - if (*end != '/') { - Tcl_Panic("no / in executable path name"); - } - i = (end - start) + 1; - pipeDllPtr = Tcl_NewStringObj(start, i); - Tcl_AppendToObj(pipeDllPtr, Tcl_DStringValue(&pipeDll), -1); - Tcl_IncrRefCount(pipeDllPtr); - if (Tcl_FSConvertToPathType(interp, pipeDllPtr) != TCL_OK) { - Tcl_Panic("Tcl_FSConvertToPathType failed"); - } - fileExists = (Tcl_FSAccess(pipeDllPtr, F_OK) == 0); - if (!fileExists) { - Tcl_Panic("Tcl pipe dll \"%s\" not found", - Tcl_DStringValue(&pipeDll)); + Tcl_DStringInit(&pipeDll); + Tcl_DStringAppend(&pipeDll, TCL_PIPE_DLL, -1); + tclExePtr = TclGetObjNameOfExecutable(); + Tcl_IncrRefCount(tclExePtr); + start = Tcl_GetStringFromObj(tclExePtr, &i); + for (end = start + (i-1); end > start; end--) { + if (*end == '/') { + break; } - Tcl_DStringAppend(&cmdLine, Tcl_DStringValue(&pipeDll), -1); + } + if (*end != '/') { + Tcl_AppendResult(interp, "no / in executable path name \"", + start, "\"", (char *) NULL); + Tcl_DecrRefCount(tclExePtr); + Tcl_DStringFree(&pipeDll); + goto end; + } + i = (end - start) + 1; + pipeDllPtr = Tcl_NewStringObj(start, i); + Tcl_AppendToObj(pipeDllPtr, Tcl_DStringValue(&pipeDll), -1); + Tcl_IncrRefCount(pipeDllPtr); + if (Tcl_FSConvertToPathType(interp, pipeDllPtr) != TCL_OK) { + Tcl_Panic("Tcl_FSConvertToPathType failed"); + } + fileExists = (Tcl_FSAccess(pipeDllPtr, F_OK) == 0); + if (!fileExists) { + Tcl_AppendResult(interp, "Tcl pipe dll \"", + Tcl_DStringValue(&pipeDll), "\" not found", + (char *) NULL); Tcl_DecrRefCount(tclExePtr); Tcl_DecrRefCount(pipeDllPtr); Tcl_DStringFree(&pipeDll); + goto end; } + Tcl_DStringAppend(&cmdLine, Tcl_DStringValue(&pipeDll), -1); + Tcl_DecrRefCount(tclExePtr); + Tcl_DecrRefCount(pipeDllPtr); + Tcl_DStringFree(&pipeDll); } } |