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:
parent
e1c56a6321
commit
6eec2eb3b4
2
tr.c
2
tr.c
@ -85,7 +85,7 @@ makeset(char *str, struct range **set, int (**check)(Rune))
|
|||||||
if (rstr[i] == '[') {
|
if (rstr[i] == '[') {
|
||||||
j = i;
|
j = i;
|
||||||
nextbrack:
|
nextbrack:
|
||||||
if (j == len)
|
if (j >= len)
|
||||||
goto literal;
|
goto literal;
|
||||||
for (m = j; m < len; m++)
|
for (m = j; m < len; m++)
|
||||||
if (rstr[m] == ']') {
|
if (rstr[m] == ']') {
|
||||||
|
Loading…
Reference in New Issue
Block a user