tr: Fix infinite loop

When `makeset` got a string containing square brackets
followed by at least one extra character, e.g. "[abc]d",
it entered an infinite loop because it was assumed
`j` could not exceed `len` without having been equal to `len`.
It can, however, when `m == len` and subsequently `j = m + 1`.
This commit is contained in:
Pieter Kockx 2017-10-04 02:25:41 +02:00 committed by Michael Forney
parent e1c56a6321
commit 6eec2eb3b4
1 changed files with 1 additions and 1 deletions

2
tr.c
View File

@ -85,7 +85,7 @@ makeset(char *str, struct range **set, int (**check)(Rune))
if (rstr[i] == '[') {
j = i;
nextbrack:
if (j == len)
if (j >= len)
goto literal;
for (m = j; m < len; m++)
if (rstr[m] == ']') {