Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf2b0a1

Browse files
committed
Fix crash on compiling a regular expression with more than 32k colors.
Throw an error instead.Backpatch to all supported branches.
1 parentd7d5832 commitbf2b0a1

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

‎src/backend/regex/regc_color.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,15 @@ newcolor(struct colormap * cm)
247247
/* oops, must allocate more */
248248
structcolordesc*newCd;
249249

250+
if (cm->max==MAX_COLOR)
251+
{
252+
CERR(REG_ECOLORS);
253+
returnCOLORLESS;/* too many colors */
254+
}
255+
250256
n=cm->ncds*2;
257+
if (n>MAX_COLOR+1)
258+
n=MAX_COLOR+1;
251259
if (cm->cd==cm->cdspace)
252260
{
253261
newCd= (structcolordesc*)MALLOC(n*sizeof(structcolordesc));

‎src/include/regex/regerrs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777
{
7878
REG_ETOOBIG,"REG_ETOOBIG","nfa has too many states"
7979
},
80+
81+
{
82+
REG_ECOLORS,"REG_ECOLORS","too many colors"
83+
},

‎src/include/regex/regex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ typedef struct
153153
#defineREG_MIXED17/* character widths of regex and string differ */
154154
#defineREG_BADOPT18/* invalid embedded option */
155155
#defineREG_ETOOBIG 19/* nfa has too many states */
156+
#defineREG_ECOLORS 20/* too many colors */
156157
/* two specials for debugging and testing */
157158
#defineREG_ATOI101/* convert error-code name to number */
158159
#defineREG_ITOA102/* convert error-code number to name */

‎src/include/regex/regguts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
typedefshortcolor;/* colors of characters */
149149
typedefintpcolor;/* what color promotes to */
150150

151+
#defineMAX_COLOR32767/* max color (must fit in 'color' datatype) */
151152
#defineCOLORLESS(-1)/* impossible color */
152153
#defineWHITE0/* default color, parent of all others */
153154

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp