summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-04-06 19:14:48 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-04-06 19:14:48 (GMT)
commit434c0fa7fb9325a185b818578e7d80e2cb6b37fe (patch)
treefabd3d26d3d70794b906c6a871692b336f8a593c /generic
parent27f230c6bf59b38ce4490468093692084b37e7f0 (diff)
parent634c443219ba3420c6a3403b7c1565076d86dbae (diff)
downloadtcl-434c0fa7fb9325a185b818578e7d80e2cb6b37fe.zip
tcl-434c0fa7fb9325a185b818578e7d80e2cb6b37fe.tar.gz
tcl-434c0fa7fb9325a185b818578e7d80e2cb6b37fe.tar.bz2
Merge 8.7. Update two macros to TIP 445.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInt.h16
-rw-r--r--generic/tclProcess.c5
-rw-r--r--generic/tclScan.c19
-rw-r--r--generic/tclStringObj.c3
-rw-r--r--generic/tclStringRep.h1
5 files changed, 33 insertions, 11 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 468758e..5e6a5fe 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4642,18 +4642,18 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
#define TclSetIntObj(objPtr, i) \
do { \
+ Tcl_ObjIntRep ir; \
+ ir.wideValue = (Tcl_WideInt) i; \
TclInvalidateStringRep(objPtr); \
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.wideValue = (Tcl_WideInt)(i); \
- (objPtr)->typePtr = &tclIntType; \
+ Tcl_StoreIntRep(objPtr, &tclIntType, &ir); \
} while (0)
#define TclSetDoubleObj(objPtr, d) \
- do { \
- TclInvalidateStringRep(objPtr); \
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.doubleValue = (double)(d); \
- (objPtr)->typePtr = &tclDoubleType; \
+ do { \
+ Tcl_ObjIntRep ir; \
+ ir.doubleValue = (double) d; \
+ TclInvalidateStringRep(objPtr); \
+ Tcl_StoreIntRep(objPtr, &tclDoubleType, &ir); \
} while (0)
/*
diff --git a/generic/tclProcess.c b/generic/tclProcess.c
index 7187ee4..604b7ce 100644
--- a/generic/tclProcess.c
+++ b/generic/tclProcess.c
@@ -887,6 +887,7 @@ TclProcessWait(
* First search for pid in table.
*/
+ Tcl_MutexLock(&infoTablesMutex);
entry = Tcl_FindHashEntry(&infoTablePerPid, pid);
if (!entry) {
/*
@@ -897,6 +898,7 @@ TclProcessWait(
msgObjPtr, errorObjPtr);
if (msgObjPtr && *msgObjPtr) Tcl_IncrRefCount(*msgObjPtr);
if (errorObjPtr && *errorObjPtr) Tcl_IncrRefCount(*errorObjPtr);
+ Tcl_MutexUnlock(&infoTablesMutex);
return result;
}
@@ -906,6 +908,7 @@ TclProcessWait(
* Process has completed but TclProcessWait has already been called,
* so report no change.
*/
+ Tcl_MutexUnlock(&infoTablesMutex);
return TCL_PROCESS_UNCHANGED;
}
@@ -915,6 +918,7 @@ TclProcessWait(
/*
* No change, stop there.
*/
+ Tcl_MutexUnlock(&infoTablesMutex);
return TCL_PROCESS_UNCHANGED;
}
@@ -948,5 +952,6 @@ TclProcessWait(
info->purge = 1;
}
+ Tcl_MutexUnlock(&infoTablesMutex);
return result;
}
diff --git a/generic/tclScan.c b/generic/tclScan.c
index a24583e..3ab3ce6 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -941,11 +941,24 @@ Tcl_ScanObjCmd(
} else if (flags & SCAN_BIG) {
if (flags & SCAN_UNSIGNED) {
mp_int big;
- if ((Tcl_GetBignumFromObj(interp, objPtr, &big) != TCL_OK)
- || mp_isneg(&big)) {
+ int code = Tcl_GetBignumFromObj(interp, objPtr, &big);
+
+ if (code == TCL_OK) {
+ if (mp_isneg(&big)) {
+ code = TCL_ERROR;
+ }
+ mp_clear(&big);
+ }
+
+ if (code == TCL_ERROR) {
+ if (objs != NULL) {
+ ckfree(objs);
+ }
+ Tcl_DecrRefCount(objPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unsigned bignum scans are invalid", -1));
- Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADUNSIGNED",NULL);
+ Tcl_SetErrorCode(interp, "TCL", "FORMAT",
+ "BADUNSIGNED",NULL);
return TCL_ERROR;
}
}
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 816252d..93691a3 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1972,6 +1972,7 @@ Tcl_AppendFormatToObj(
if (cmpResult == MP_EQ) gotHash = 0;
if (ch == 'u') {
if (isNegative) {
+ mp_clear(&big);
msg = "unsigned bignum format is invalid";
errCode = "BADUNSIGNED";
goto errorMsg;
@@ -3205,6 +3206,8 @@ TclStringCat(
dst += more;
}
}
+ /* Must NUL-terminate! */
+ *dst = '\0';
}
return objResultPtr;
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index 1ef1957..fc5a713 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -86,6 +86,7 @@ typedef struct {
#define GET_STRING(objPtr) \
((String *) (objPtr)->internalRep.twoPtrValue.ptr1)
#define SET_STRING(objPtr, stringPtr) \
+ ((objPtr)->internalRep.twoPtrValue.ptr2 = NULL), \
((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (stringPtr))
/*