shuf: fix a segfault on 'shuf -e'

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Bartosz Golaszewski 2014-03-07 11:46:03 +01:00 committed by Denys Vlasenko
parent 0ed5f7aacd
commit 58adbb5505

View File

@ -126,7 +126,8 @@ int shuf_main(int argc, char **argv)
fclose_if_not_stdin(fp);
}
shuffle_lines(lines, numlines);
if (numlines != 0)
shuffle_lines(lines, numlines);
if (opts & OPT_o)
xmove_fd(xopen(opt_o_str, O_WRONLY|O_CREAT|O_TRUNC), STDOUT_FILENO);