summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclCmdAH.c17
-rw-r--r--generic/tclInt.h9
2 files changed, 19 insertions, 7 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 7fab2f0..dff231d 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -13,6 +13,7 @@
#include "tclInt.h"
#include "tclIO.h"
+#include "tclTomMath.h"
#ifdef _WIN32
# include "tclWinInt.h"
#endif
@@ -580,13 +581,15 @@ EncodingConvertfromObjCmd(
* data as was converted.
*/
if (failVarObj) {
- /* I hope, wide int will cover Tcl_Size data type */
+ Tcl_Obj *failIndex;
+ TclNewIndexObj(failIndex, errorLocation);
if (Tcl_ObjSetVar2(interp,
failVarObj,
NULL,
- Tcl_NewWideIntObj(errorLocation),
+ failIndex,
TCL_LEAVE_ERR_MSG) == NULL) {
- Tcl_DStringFree(&ds);
+ Tcl_DecrRefCount(failIndex);
+ Tcl_DStringFree(&ds);
return TCL_ERROR;
}
}
@@ -676,13 +679,15 @@ EncodingConverttoObjCmd(
* data as was converted.
*/
if (failVarObj) {
- /* I hope, wide int will cover Tcl_Size data type */
+ Tcl_Obj *failIndex;
+ TclNewIndexObj(failIndex, errorLocation);
if (Tcl_ObjSetVar2(interp,
failVarObj,
NULL,
- Tcl_NewWideIntObj(errorLocation),
+ failIndex,
TCL_LEAVE_ERR_MSG) == NULL) {
- Tcl_DStringFree(&ds);
+ Tcl_DecrRefCount(failIndex);
+ Tcl_DStringFree(&ds);
return TCL_ERROR;
}
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index a90ac79..aa9247f 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4912,7 +4912,14 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
} while (0)
#define TclNewIndexObj(objPtr, w) \
- (objPtr) = (((Tcl_WideUInt)w) >= TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w)
+ do {
+ Tcl_WideUInt _uw = (Tcl_WideUInt)w;
+ if (_uw >= TCL_INDEX_NONE) {
+ TclNewIntObj(objPtr, -1);
+ } else {
+ TclNewUIntObj(objPtr, w);
+ }
+ } while (0)
#define TclNewDoubleObj(objPtr, d) \
(objPtr) = Tcl_NewDoubleObj(d)