aboutsummaryrefslogtreecommitdiff
path: root/src/backend/regex
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-04-04 19:04:57 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-04-04 19:48:11 +0300
commitbf2b0a147857f63daa2e5c17eed0169861371af8 (patch)
treec075c53dbb17fddcec93e53c1bd097e5e26af4ff /src/backend/regex
parentd7d5832012ae5174707643af1a450d26d3350719 (diff)
downloadpostgresql-bf2b0a147857f63daa2e5c17eed0169861371af8.tar.gz
postgresql-bf2b0a147857f63daa2e5c17eed0169861371af8.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.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c
index 1c60566fbf5..e6aa899518f 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));