summaryrefslogtreecommitdiffstats
path: root/generic/regc_color.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-04-08 20:07:07 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-04-08 20:07:07 (GMT)
commite7f6b7f4fb45169bccbd300eb6931712d90aeae4 (patch)
tree95837b1887eda849b2873c00caaf5337bbfc18dd /generic/regc_color.c
parente51453c41298f99bcf7ea71f57c69463d5b904a9 (diff)
parentb33c30f98bfe09a38ef7a2106610e2d0d0605a45 (diff)
downloadtcl-e7f6b7f4fb45169bccbd300eb6931712d90aeae4.zip
tcl-e7f6b7f4fb45169bccbd300eb6931712d90aeae4.tar.gz
tcl-e7f6b7f4fb45169bccbd300eb6931712d90aeae4.tar.bz2
3610026 Stop crash when the number of "colors" in a regular expression
overflows a short int. Thanks to Heikki Linnakangas for the report and the patch.
Diffstat (limited to 'generic/regc_color.c')
-rw-r--r--generic/regc_color.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/generic/regc_color.c b/generic/regc_color.c
index b7a571c..f5d6dfd 100644
--- a/generic/regc_color.c
+++ b/generic/regc_color.c
@@ -254,7 +254,14 @@ newcolor(
* Oops, must allocate more.
*/
+ if (cm->max == MAX_COLOR) {
+ CERR(REG_ECOLORS);
+ return COLORLESS; /* too many colors */
+ }
n = cm->ncds * 2;
+ if (n < MAX_COLOR + 1) {
+ n = MAX_COLOR + 1;
+ }
if (cm->cd == cm->cdspace) {
newCd = (struct colordesc *) MALLOC(n * sizeof(struct colordesc));
if (newCd != NULL) {