summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclInterp.c22
-rw-r--r--tests/interp.test4
2 files changed, 13 insertions, 13 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index a263a66..d63add2 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -4785,7 +4785,7 @@ ChildTimeLimitCmd(
Tcl_Obj *milliObj = NULL, *secObj = NULL;
int gran = 0;
Tcl_Time limitMoment;
- int tmp;
+ Tcl_WideInt tmp;
Tcl_LimitGetTime(childInterp, &limitMoment);
for (i=consumedObjc ; i<objc ; i+=2) {
@@ -4817,17 +4817,17 @@ ChildTimeLimitCmd(
if (milliLen == 0) {
break;
}
- if (TclGetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
+ if (TclGetWideIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
return TCL_ERROR;
}
- if (tmp < 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "milliseconds must be at least 0", -1));
+ if (tmp < 0 || tmp > LONG_MAX) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "milliseconds must be between 0 and %ld", LONG_MAX));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", NULL);
return TCL_ERROR;
}
- limitMoment.usec = ((long) tmp)*1000;
+ limitMoment.usec = ((long)tmp)*1000;
break;
case OPT_SEC:
secObj = objv[i+1];
@@ -4835,17 +4835,17 @@ ChildTimeLimitCmd(
if (secLen == 0) {
break;
}
- if (TclGetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
+ if (TclGetWideIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
return TCL_ERROR;
}
- if (tmp < 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "seconds must be at least 0", -1));
+ if (tmp < 0 || tmp > LONG_MAX) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "seconds must be between 0 and %ld", LONG_MAX));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "INTERP",
"BADVALUE", NULL);
return TCL_ERROR;
}
- limitMoment.sec = tmp;
+ limitMoment.sec = (long)tmp;
break;
}
}
diff --git a/tests/interp.test b/tests/interp.test
index c19755f..385d3e2 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -3524,7 +3524,7 @@ test interp-35.19 {interp limit syntax} -body {
interp limit $i time -seconds -1
} -cleanup {
interp delete $i
-} -returnCodes error -result {seconds must be at least 0}
+} -match glob -returnCodes error -result {seconds must be between 0 and *}
test interp-35.20 {interp limit syntax} -body {
set i [interp create]
interp limit $i time -millis foobar
@@ -3536,7 +3536,7 @@ test interp-35.21 {interp limit syntax} -body {
interp limit $i time -millis -1
} -cleanup {
interp delete $i
-} -returnCodes error -result {milliseconds must be at least 0}
+} -match glob -returnCodes error -result {milliseconds must be between 0 and *}
test interp-35.22 {interp time limits normalize milliseconds} -body {
set i [interp create]
interp limit $i time -seconds 1 -millis 1500