aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/tr.c6
-rw-r--r--tr.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/coreutils/tr.c b/coreutils/tr.c
index 48cdd47bd..5a8116db0 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -187,10 +187,12 @@ extern int tr_main(int argc, char **argv)
expand(argv[index++], input);
if (com_fl)
complement(input);
- if (argv[index] != NULL)
+ if (argv[index] != NULL) {
+ if (*argv[index] == '\0')
+ fatalError("tr: STRING2 cannot be empty\n");
expand(argv[index], output);
- if (argv[index] != NULL)
map(input, output);
+ }
for (ptr = input; *ptr; ptr++)
invec[*ptr] = TRUE;
for (ptr = output; *ptr; ptr++)
diff --git a/tr.c b/tr.c
index 48cdd47bd..5a8116db0 100644
--- a/tr.c
+++ b/tr.c
@@ -187,10 +187,12 @@ extern int tr_main(int argc, char **argv)
expand(argv[index++], input);
if (com_fl)
complement(input);
- if (argv[index] != NULL)
+ if (argv[index] != NULL) {
+ if (*argv[index] == '\0')
+ fatalError("tr: STRING2 cannot be empty\n");
expand(argv[index], output);
- if (argv[index] != NULL)
map(input, output);
+ }
for (ptr = input; *ptr; ptr++)
invec[*ptr] = TRUE;
for (ptr = output; *ptr; ptr++)