File tree 4 files changed +14
-0
lines changed
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)
247
247
/* oops, must allocate more */
248
248
struct colordesc * newCd ;
249
249
250
+ if (cm -> max == MAX_COLOR )
251
+ {
252
+ CERR (REG_ECOLORS );
253
+ return COLORLESS ; /* too many colors */
254
+ }
255
+
250
256
n = cm -> ncds * 2 ;
257
+ if (n > MAX_COLOR + 1 )
258
+ n = MAX_COLOR + 1 ;
251
259
if (cm -> cd == cm -> cdspace )
252
260
{
253
261
newCd = (struct colordesc * ) MALLOC (n * sizeof (struct colordesc ));
Original file line number Diff line number Diff line change 77
77
{
78
78
REG_ETOOBIG , "REG_ETOOBIG" , "nfa has too many states"
79
79
},
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
153
153
#define REG_MIXED 17 /* character widths of regex and string differ */
154
154
#define REG_BADOPT 18 /* invalid embedded option */
155
155
#define REG_ETOOBIG 19 /* nfa has too many states */
156
+ #define REG_ECOLORS 20 /* too many colors */
156
157
/* two specials for debugging and testing */
157
158
#define REG_ATOI 101 /* convert error-code name to number */
158
159
#define REG_ITOA 102 /* convert error-code number to name */
Original file line number Diff line number Diff line change 148
148
typedef short color ; /* colors of characters */
149
149
typedef int pcolor ; /* what color promotes to */
150
150
151
+ #define MAX_COLOR 32767 /* max color (must fit in 'color' datatype) */
151
152
#define COLORLESS (-1) /* impossible color */
152
153
#define WHITE 0 /* default color, parent of all others */
153
154
You can’t perform that action at this time.
0 commit comments