diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-04-04 19:04:57 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-04-04 19:32:20 +0300 |
commit | 7a30f29b05043939a95c178068b215efd489348d (patch) | |
tree | f5ef2135f522fdd94b1806a1c5a201b95f174558 /src/backend/regex | |
parent | 292f7b27260aaebd27f66db2fc14e8c8da975513 (diff) | |
download | postgresql-7a30f29b05043939a95c178068b215efd489348d.tar.gz postgresql-7a30f29b05043939a95c178068b215efd489348d.zip |
Fix crash on compiling a regular expression with more than 32k colors.
Throw an error instead.
Backpatch to all supported branches.
Diffstat (limited to 'src/backend/regex')
-rw-r--r-- | src/backend/regex/regc_color.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c index 99c28505ae9..846f24f7c28 100644 --- a/src/backend/regex/regc_color.c +++ b/src/backend/regex/regc_color.c @@ -247,7 +247,15 @@ newcolor(struct colormap * cm) /* oops, must allocate more */ struct colordesc *newCd; + 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)); |