[git commit] shuf: fix a segfault on 'shuf -e'

Denys Vlasenko vda.linux at googlemail.com
Fri Mar 7 10:46:03 UTC 2014


commit: http://git.busybox.net/busybox/commit/?id=58adbb5505d0c643c18d956934aa8afa18e612eb
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Bartosz Golaszewski <bartekgola at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/shuf.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index f213d67..648a4ab 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -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);


More information about the busybox-cvs mailing list