aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/troff
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2007-05-08 02:52:21 +0000
committerrsc <devnull@localhost>2007-05-08 02:52:21 +0000
commit4198bd0e2eb7ce81972a27feea2ad518b8ea39da (patch)
treee697e822caf12e9ec428d8132d265cea628d3f2a /src/cmd/troff
parente17c64a7cd5162ee586f4b1bdd797f64381859d9 (diff)
downloadplan9port-4198bd0e2eb7ce81972a27feea2ad518b8ea39da.tar.gz
plan9port-4198bd0e2eb7ce81972a27feea2ad518b8ea39da.tar.bz2
plan9port-4198bd0e2eb7ce81972a27feea2ad518b8ea39da.zip
fix random troff crash (Noel Hunt)
Diffstat (limited to 'src/cmd/troff')
-rw-r--r--src/cmd/troff/n8.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/troff/n8.c b/src/cmd/troff/n8.c
index b2ab175b..9ff2ebce 100644
--- a/src/cmd/troff/n8.c
+++ b/src/cmd/troff/n8.c
@@ -400,7 +400,7 @@ static int texit(Tchar *start, Tchar *end) /* hyphenate as in tex, return # foun
for (i = 0; i <= nw; i++)
cnt[i] = '0';
- for (wp = w; wp < w + nw; wp++) {
+ for (wp = w; wp+1 < w+nw; wp++) {
for (pp = trie[trieindex(*wp, *(wp+1))]; pp < nextpat; ) {
if (pp == 0 /* no trie entry */
|| *pp != *wp /* no match on 1st letter */
@@ -537,5 +537,9 @@ static void fixup(void) /* build indexes of where . a b c ... start */
static int trieindex(int d1, int d2)
{
- return 27 * (d1 == '.' ? 0 : d1 - 'a' + 1) + (d2 == '.' ? 0 : d2 - 'a' + 1);
+ int z;
+
+ z = 27 * (d1 == '.' ? 0 : d1 - 'a' + 1) + (d2 == '.' ? 0 : d2 - 'a' + 1);
+ assert(z >= 0 && z < 27*27);
+ return z;
}