File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,15 @@ newcolor(struct colormap * cm)
247247 /* oops, must allocate more */
248248 struct colordesc * newCd ;
249249
250+ if (cm -> max == MAX_COLOR )
251+ {
252+ CERR (REG_ECOLORS );
253+ return COLORLESS ; /* 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 = (struct colordesc * ) MALLOC (n * sizeof (struct colordesc ));
Original file line number Diff line number Diff line change 7777{
7878 REG_ETOOBIG , "REG_ETOOBIG" , "nfa has too many states"
7979},
80+
81+ {
82+ REG_ECOLORS , "REG_ECOLORS" , "too many colors"
83+ },
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ typedef struct
153153#define REG_MIXED 17 /* character widths of regex and string differ */
154154#define REG_BADOPT 18 /* invalid embedded option */
155155#define REG_ETOOBIG 19 /* nfa has too many states */
156+ #define REG_ECOLORS 20 /* too many colors */
156157/* two specials for debugging and testing */
157158#define REG_ATOI 101 /* convert error-code name to number */
158159#define REG_ITOA 102 /* convert error-code number to name */
Original file line number Diff line number Diff line change 148148typedef short color ; /* colors of characters */
149149typedef int pcolor ; /* what color promotes to */
150150
151+ #define MAX_COLOR 32767 /* max color (must fit in 'color' datatype) */
151152#define COLORLESS (-1) /* impossible color */
152153#define WHITE 0 /* default color, parent of all others */
153154
You can’t perform that action at this time.
0 commit comments