shithub: neatroff

Download patch

ref: 89223552d8a4f0d838d36021ca944283c4502523
parent: 5c346ca397e873342f74115ead3c340df28be62a
author: Ali Gholami Rudi <[email protected]>
date: Tue Jun 11 12:39:31 EDT 2013

wb: handle very long words in hyphpos()

--- a/wb.c
+++ b/wb.c
@@ -286,12 +286,12 @@
 	char d[ILNLEN];
 	char *r = NULL;
 	char *hy_beg, *hy_wid = NULL, *hy_end = NULL;
-	char *wp = word;
+	char *wp = word, *we = word + sizeof(word);
 	int beg, end;
 	int i, c;
 	skipreqs(&s, w1);
 	hy_beg = s;
-	while ((c = out_readc(&s, d)) == 0) {
+	while ((c = out_readc(&s, d)) == 0 && wp + strlen(d) + 1 < we) {
 		wb_putc(w1, c, d);
 		if (wb_wid(w1) + wb_dashwid(w1) <= w)
 			hy_wid = s;