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`.
master
Pieter Kockx 5 years ago committed by Michael Forney
parent e1c56a6321
commit 6eec2eb3b4

@ -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] == ']') {

Loading…
Cancel
Save