From 8dac135fc9c8efae2cc3113bc975ab871ff2271f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 5 Sep 2016 13:55:00 +0000 Subject: Allow additional optional "interp" argument for testinterpresolver command. Not used yet in any test-case. Protect panic in tclLiteral.c for possible null-pointer access. (cherry-picked from Gustaf Neuman's interpresolver patch). Eliminate some unecessary spacing. --- generic/tclCmdAH.c | 2 +- generic/tclExecute.c | 2 +- generic/tclLiteral.c | 3 ++- generic/tclTest.c | 13 ++++++++++--- tests/resolver.test | 2 +- win/tclWinFile.c | 8 ++++---- win/tclWinPipe.c | 2 +- win/tclWinPort.h | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 88cc17d..4c299f8 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -1597,7 +1597,7 @@ FileAttrIsOwnedCmd( Tcl_Obj *const objv[]) { #ifdef __CYGWIN__ -#define geteuid() (short)(geteuid)() +#define geteuid() (short)(geteuid)() #endif #if !defined(_WIN32) Tcl_StatBuf buf; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index e539161..34d92d3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3173,7 +3173,7 @@ TEBCresume( Tcl_Obj *copyPtr = Tcl_NewListObj(objc - opnd + 1, NULL); Tcl_ListObjAppendElement(NULL, copyPtr, objPtr); - Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, + Tcl_ListObjReplace(NULL, copyPtr, LIST_MAX, 0, objc - opnd, objv + opnd); Tcl_DecrRefCount(objPtr); objPtr = copyPtr; diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 03200ca..26c21db 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -431,12 +431,13 @@ TclRegisterLiteral( * Is it in the interpreter's global literal table? If not, create it. */ + globalPtr = NULL; objPtr = TclCreateLiteral(iPtr, bytes, length, hash, &new, nsPtr, flags, &globalPtr); objIndex = AddLocalLiteralEntry(envPtr, objPtr, localHash); #ifdef TCL_COMPILE_DEBUG - if (globalPtr->refCount < 1) { + if (globalPtr != NULL && globalPtr->refCount < 1) { Tcl_Panic("%s: global literal \"%.*s\" had bad refCount %d", "TclRegisterLiteral", (length>60? 60 : length), bytes, globalPtr->refCount); diff --git a/generic/tclTest.c b/generic/tclTest.c index e33d263..b3508f1 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -7449,9 +7449,16 @@ TestInterpResolverCmd( int idx; #define RESOLVER_KEY "testInterpResolver" - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "up|down"); - return TCL_ERROR; + if ((objc < 2) || (objc > 3)) { + Tcl_WrongNumArgs(interp, 1, objv, "up|down ?interp?"); + return TCL_ERROR; + } + if (objc == 3) { + interp = Tcl_GetSlave(interp, Tcl_GetString(objv[2])); + if (interp == NULL) { + Tcl_AppendResult(interp, "provided interpreter not found", NULL); + return TCL_ERROR; + } } if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT, &idx) != TCL_OK) { diff --git a/tests/resolver.test b/tests/resolver.test index f3d22e5..aaad02c 100644 --- a/tests/resolver.test +++ b/tests/resolver.test @@ -187,7 +187,7 @@ test resolver-2.1 {compiled var resolver: Bug #3383616} -setup { # During the compilation the compiled var resolver, the resolve-specific # var info is allocated, during the execution of the body, the variable is # fetched and cached. - x; + x # During later calls, the cached variable is reused. x # When the proc is freed, the resolver-specific resolver var info is diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 4d7500b..6662327 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -3166,8 +3166,8 @@ TclWinFileOwned( case we are in all likelihood not the owner */ return 0; } - - /* + + /* * Getting the current process SID is a multi-step process. * We make the assumption that if a call fails, this process is * so underprivileged it could not possibly own anything. Normally @@ -3191,10 +3191,10 @@ TclWinFileOwned( LocalFree(secd); /* Also frees ownerSid */ if (buf) ckfree(buf); - + return (owned != 0); /* Convert non-0 to 1 */ } - + /* * Local Variables: * mode: c diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 382addd..4666deb 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1337,7 +1337,7 @@ ApplicationType( Tcl_DStringFree(&ds); ext = strrchr(fullName, '.'); - if ((ext != NULL) && + if ((ext != NULL) && (strcasecmp(ext, ".cmd") == 0 || strcasecmp(ext, ".bat") == 0)) { applType = APPL_DOS; break; diff --git a/win/tclWinPort.h b/win/tclWinPort.h index b486466..159a708 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -360,7 +360,7 @@ typedef DWORD_PTR * PDWORD_PTR; # define S_IFLNK 0120000 /* Symbolic Link */ #endif -/* +/* * Windows compilers do not define S_IFBLK. However, Tcl uses it in * GetTypeFromMode to identify blockSpecial devices based on the * value in the statsbuf st_mode field. We have no other way to pass this -- cgit v0.12