shithub: neatroff

Download patch

ref: cb78d07d358dd55df2a7a54e03bad3e1ab2b9848
parent: 60965920e172133f0313482b7397435d2a8bd3a5
author: Ali Gholami Rudi <[email protected]>
date: Tue Apr 14 18:24:45 EDT 2015

map: print an error message when NREGS is reached

Reported by Dirk-Wilhelm Peters <[email protected]>.

--- a/map.c
+++ b/map.c
@@ -20,6 +20,8 @@
 	if (i < 0) {
 		dict_put(mapdict, s, 0);
 		i = dict_idx(mapdict, s);
+		if (MAPBEG + i >= NREGS)
+			errdie("neatroff: increase NREGS\n");
 	}
 	return MAPBEG + i;
 }
--- a/roff.h
+++ b/roff.h
@@ -30,6 +30,7 @@
 #define NMLEN		32	/* macro/register/environment/glyph name length */
 #define GNLEN		NMLEN	/* glyph name length */
 #define RNLEN		NMLEN	/* register/macro name */
+#define NREGS		8192	/* number of mapped names */
 #define ILNLEN		1000	/* line limit of input files */
 #define LNLEN		4000	/* line buffer length (ren.c/out.c) */
 #define NWORDS		1024	/* number of queued words in formatting buffer */
@@ -414,7 +415,6 @@
 #define TR_POPREN	"\07P"	/* exit render_rec() */
 
 /* mapping register, macro and environment names to indices */
-#define NREGS		4096	/* maximum number of mapped names */
 #define DOTMAP(c2)	(c2)	/* optimized mapping for ".x" names */
 
 int map(char *s);		/* map name s to an index */