tr: set2 must be set in some cases

echo abc | tr 'a' '' would crash because of:

	m--;
	r = set2[m].start + (off1 - off2) / set2[m].quant;

if set2ranges > 0 it's fine.
This commit is contained in:
Hiltjo Posthuma 2015-01-10 19:08:54 +01:00 committed by sin
parent 4469b0b641
commit 14c5ab48d5
1 changed files with 2 additions and 0 deletions

2
tr.c
View File

@ -196,6 +196,8 @@ main(int argc, char *argv[])
set1ranges = makeset(argv[0], &set1);
if (argc == 2)
set2ranges = makeset(argv[1], &set2);
if (!dflag && !set2ranges)
eprintf("set2 must be non-empty\n");
read:
if (!readrune("<stdin>", stdin, &r))
return 0;