summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclCmdIL.c2
-rw-r--r--generic/tclTest.c29
-rw-r--r--generic/tclTestObj.c12
3 files changed, 24 insertions, 19 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index a63e660..0723b40 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -2839,7 +2839,7 @@ Tcl_LremoveObjCmd(
Tcl_SetObjResult(interp, listObj);
return TCL_OK;
}
- idxv = (Tcl_Size *)Tcl_Alloc((objc - 2) * sizeof(*idxv));
+ idxv = (Tcl_Size *)ckalloc((objc - 2) * sizeof(*idxv));
for (i = 2; i < objc; i++) {
status = (TclGetIntForIndexM(interp, objv[i], /*endValue*/ listLen - 1,
&idxv[i - 2]) != TCL_OK);
diff --git a/generic/tclTest.c b/generic/tclTest.c
index c73cd5e..72190e2 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -236,10 +236,7 @@ static Tcl_ResolveCompiledVarProc InterpCompiledVarResolver;
static void MainLoop(void);
static Tcl_CmdProc NoopCmd;
static Tcl_ObjCmdProc NoopObjCmd;
-static int ObjTraceProc(void *clientData,
- Tcl_Interp *interp, int level, const char *command,
- Tcl_Command commandToken, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_CmdObjTraceProc ObjTraceProc;
static void ObjTraceDeleteProc(void *clientData);
static void PrintParse(Tcl_Interp *interp, Tcl_Parse *parsePtr);
static void SpecialFree(char *blockPtr);
@@ -1167,6 +1164,8 @@ TestcmdinfoObjCmd(
Tcl_AppendResult(interp, " stringProc", NULL);
} else if (info.isNativeObjectProc == 1) {
Tcl_AppendResult(interp, " nativeObjectProc", NULL);
+ } else if (info.isNativeObjectProc == 2) {
+ Tcl_AppendResult(interp, " nativeObjectProc2", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("Invalid isNativeObjectProc value %d",
info.isNativeObjectProc));
@@ -1299,7 +1298,7 @@ TestcmdtokenCmd(
return TCL_ERROR;
}
if (strcmp(argv[1], "create") == 0) {
- refPtr = (TestCommandTokenRef *)Tcl_Alloc(sizeof(TestCommandTokenRef));
+ refPtr = (TestCommandTokenRef *)ckalloc(sizeof(TestCommandTokenRef));
refPtr->token = Tcl_CreateCommand(interp, argv[2], CmdProc0,
refPtr, CmdDelProc0);
refPtr->id = nextCommandTokenRefId;
@@ -1506,10 +1505,10 @@ static int
ObjTraceProc(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Tcl interpreter */
- TCL_UNUSED(int) /*level*/,
+ TCL_UNUSED(int) /* level */,
const char *command,
TCL_UNUSED(Tcl_Command),
- TCL_UNUSED(int) /*objc*/,
+ TCL_UNUSED(int) /* objc */,
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *word = Tcl_GetString(objv[0]);
@@ -5724,7 +5723,10 @@ TestbytestringObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
- Tcl_Size n = 0;
+ struct {
+ Tcl_Size n;
+ int m; /* This variable should not be overwritten */
+ } x = {0, 1};
const char *p;
if (objc != 2) {
@@ -5732,11 +5734,15 @@ TestbytestringObjCmd(
return TCL_ERROR;
}
- p = (const char *)Tcl_GetBytesFromObj(interp, objv[1], &n);
+ p = (const char *)Tcl_GetBytesFromObj(interp, objv[1], &x.n);
if (p == NULL) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(p, n));
+ if (x.m != 1) {
+ Tcl_AppendResult(interp, "Tcl_GetBytesFromObj() overwrites variable", NULL);
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(p, x.n));
return TCL_OK;
}
@@ -8653,7 +8659,7 @@ MyCompiledVarFetch(
}
hPtr = Tcl_CreateHashEntry((Tcl_HashTable *) &iPtr->globalNsPtr->varTable,
- (char *) resVarInfo->nameObj, &isNewVar);
+ (char *)resVarInfo->nameObj, &isNewVar);
if (hPtr) {
var = (Tcl_Var) TclVarHashGetValue(hPtr);
} else {
@@ -8822,4 +8828,3 @@ int TestApplyLambdaObjCmd (
* indent-tabs-mode: nil
* End:
*/
-
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 0080938..b4d70f0 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -101,7 +101,7 @@ TclObjTest_Init(
*/
Tcl_Obj **varPtr;
- varPtr = (Tcl_Obj **) ckalloc(NUMBER_OF_OBJECT_VARS *sizeof(varPtr[0]));
+ varPtr = (Tcl_Obj **)ckalloc(NUMBER_OF_OBJECT_VARS *sizeof(varPtr[0]));
if (!varPtr) {
return TCL_ERROR;
}
@@ -1063,15 +1063,15 @@ TestobjCmd(
const Tcl_ObjType *targetType;
Tcl_Obj **varPtr;
const char *subcommands[] = {
- "freeallvars", "bug3598580", "types",
- "objtype", "newobj", "set",
+ "freeallvars", "bug3598580",
+ "types", "objtype", "newobj", "set",
"assign", "convert", "duplicate",
"invalidateStringRep", "refcount", "type",
NULL
};
enum testobjCmdIndex {
- TESTOBJ_FREEALLVARS, TESTOBJ_BUG3598580, TESTOBJ_TYPES,
- TESTOBJ_OBJTYPE, TESTOBJ_NEWOBJ, TESTOBJ_SET,
+ TESTOBJ_FREEALLVARS, TESTOBJ_BUG3598580,
+ TESTOBJ_TYPES, TESTOBJ_OBJTYPE, TESTOBJ_NEWOBJ, TESTOBJ_SET,
TESTOBJ_ASSIGN, TESTOBJ_CONVERT, TESTOBJ_DUPLICATE,
TESTOBJ_INVALIDATESTRINGREP, TESTOBJ_REFCOUNT, TESTOBJ_TYPE,
} cmdIndex;
@@ -1535,7 +1535,7 @@ TeststringobjCmd(
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 13: /* newunicode*/
- unicode = (unsigned short *) ckalloc(((unsigned)objc - 3) * sizeof(unsigned short));
+ unicode = (unsigned short *)ckalloc(((unsigned)objc - 3) * sizeof(unsigned short));
for (i = 0; i < (objc - 3); ++i) {
int val;
if (Tcl_GetIntFromObj(interp, objv[i + 3], &val) != TCL_OK) {