From 6def7f622770acefde65603432c4bf216948d44e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 26 Jun 2006 08:39:59 +0000 Subject: [PATCH] Avoid a segfault for wc --files0=- < /dev/null. * src/wc.c (compute_number_width): Return right away if nfiles == 0. --- ChangeLog | 5 +++++ src/wc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 66673af..2efa74a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-26 Jim Meyering + + Avoid a segfault for wc --files0=- < /dev/null. + * src/wc.c (compute_number_width): Return right away if nfiles == 0. + 2006-06-25 Jim Meyering * NEWS: wc accepts a new option --files0-from=FILE, where FILE diff --git a/src/wc.c b/src/wc.c index 29c6240..1da5373 100644 --- a/src/wc.c +++ b/src/wc.c @@ -573,7 +573,7 @@ compute_number_width (int nfiles, struct fstatus const *fstatus) { int width = 1; - if (fstatus[0].failed <= 0) + if (0 < nfiles && fstatus[0].failed <= 0) { int minimum_width = 1; uintmax_t regular_total = 0; -- 2.7.4