sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 14c5ab48d504c35fd0f4d196ca11e6f9a6aaff33
parent 4469b0b64114e1162e42bb52fc3f7bcc24c8b821
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 10 Jan 2015 19:08:54 +0100

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.

Diffstat:
tr.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/tr.c b/tr.c @@ -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;