summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclScan.c19
-rw-r--r--generic/tclStringObj.c1
2 files changed, 17 insertions, 3 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 4d6b28e..f78d88b 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 3880a10..b80f668 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1946,6 +1946,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;