From 14c5ab48d504c35fd0f4d196ca11e6f9a6aaff33 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 10 Jan 2015 19:08:54 +0100 Subject: [PATCH] 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. --- tr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tr.c b/tr.c index 03a7c2a..973c73b 100644 --- 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, &r)) return 0;