summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-22 17:11:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-22 17:11:58 (GMT)
commit393936e2b829ec47b742c3225bb29250a8e728b8 (patch)
tree9e3c2fbb691e02ea80a48f8073b6028042246971 /generic/tclCmdMZ.c
parent185db606f066a1ec6904691d6446ef62e184f674 (diff)
downloadtcl-393936e2b829ec47b742c3225bb29250a8e728b8.zip
tcl-393936e2b829ec47b742c3225bb29250a8e728b8.tar.gz
tcl-393936e2b829ec47b742c3225bb29250a8e728b8.tar.bz2
Proposed fix for [76ad7aeba3]: boundary case bug in [string is integer]. Missing: more unit-tests
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index c94abbd..8d3eda9 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1451,7 +1451,6 @@ StringIsCmd(
int (*chcomp)(int) = NULL; /* The UniChar comparison function. */
int i, failat = 0, result = 1, strict = 0, index, length1, length2;
Tcl_Obj *objPtr, *failVarObj = NULL;
- Tcl_WideInt w;
static const char *const isClasses[] = {
"alnum", "alpha", "ascii", "control",
@@ -1590,9 +1589,13 @@ StringIsCmd(
case STR_IS_GRAPH:
chcomp = Tcl_UniCharIsGraph;
break;
- case STR_IS_INT:
- if (TCL_OK == TclGetIntFromObj(NULL, objPtr, &i)) {
- break;
+ case STR_IS_INT: {
+ void *p;
+ int type;
+ if (TCL_OK == TclGetNumberFromObj(NULL, objPtr, &p, &type)
+ && (type == TCL_NUMBER_LONG) && (*(long *)p <= INT_MAX) && (*(long *)p >= INT_MIN)) {
+ break;
+ }
}
goto failedIntParse;
case STR_IS_ENTIER:
@@ -1640,9 +1643,13 @@ StringIsCmd(
failat = 0;
}
break;
- case STR_IS_WIDE:
- if (TCL_OK == TclGetWideIntFromObj(NULL, objPtr, &w)) {
- break;
+ case STR_IS_WIDE: {
+ void *p;
+ int type;
+ if (TCL_OK == TclGetNumberFromObj(NULL, objPtr, &p, &type)
+ && (type == TCL_NUMBER_WIDE)) {
+ break;
+ }
}
failedIntParse: