summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-06-08 21:05:22 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-06-08 21:05:22 (GMT)
commit7c926553f6dcae359d48cc16d1ace1291a5dfb4b (patch)
treec9ccf23582095d1b977962aa076ac4de4283aeb4
parente0cae6298f8e3795aa4cbabcb5758ba856d78959 (diff)
downloadtcl-7c926553f6dcae359d48cc16d1ace1291a5dfb4b.zip
tcl-7c926553f6dcae359d48cc16d1ace1291a5dfb4b.tar.gz
tcl-7c926553f6dcae359d48cc16d1ace1291a5dfb4b.tar.bz2
Modernize overflow checks.
-rw-r--r--generic/tclStringObj.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 31a6b26..43f8016 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2916,10 +2916,10 @@ TclStringCatObjv(
last = objc - oc;
if (length == 0) {
first = last;
- }
- if ((length += numBytes) < 0) {
+ } else if (numBytes > INT_MAX - length) {
goto overflow;
}
+ length += numBytes;
}
}
} while (--oc);
@@ -2937,10 +2937,10 @@ TclStringCatObjv(
last = objc - oc;
if (length == 0) {
first = last;
- }
- if ((length += numChars) < 0) {
+ } else if (numChars > INT_MAX - length) {
goto overflow;
}
+ length += numChars;
}
}
} while (--oc);
@@ -2973,10 +2973,10 @@ TclStringCatObjv(
}
if (length == 0) {
first = last;
- }
- if ((length += numBytes) < 0) {
+ } else if (numBytes > INT_MAX - length) {
goto overflow;
}
+ length += numBytes;
}
} while (--oc);
}