summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-06-26 08:39:59 +0000
committerJim Meyering <jim@meyering.net>2006-06-26 08:39:59 +0000
commit6def7f622770acefde65603432c4bf216948d44e (patch)
tree68f5a0baf56ba0c0db60199abe8974245b8d71fe
parentd77808bb40f70f60f6e0c2309a33fec36d36c4e5 (diff)
downloadcoreutils-6def7f622770acefde65603432c4bf216948d44e.tar.xz
Avoid a segfault for wc --files0=- < /dev/null.
* src/wc.c (compute_number_width): Return right away if nfiles == 0.
-rw-r--r--ChangeLog5
-rw-r--r--src/wc.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 66673af2d..2efa74a90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-26 Jim Meyering <jim@meyering.net>
+
+ 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 <jim@meyering.net>
* NEWS: wc accepts a new option --files0-from=FILE, where FILE
diff --git a/src/wc.c b/src/wc.c
index 29c624015..1da5373e3 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;