summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-05-05 15:20:13 +0100
committerPádraig Brady <P@draigBrady.com>2011-05-05 16:32:14 +0100
commit9aeffd3fe549116c043b61ec0d593a7d4c004a44 (patch)
tree77e3fc07dabec0ec72c3f777d7695699e7f39e84 /src
parent719dcc7f016e72a6ff4da721c678a78f38c445ad (diff)
downloadcoreutils-9aeffd3fe549116c043b61ec0d593a7d4c004a44.tar.xz
df: fix crash in mem exhaustion edge case
* src/df.c (print_table): Don't try to output NULL if ambsalign() can't allocate memory. Instead just output the unaligned text.
Diffstat (limited to 'src')
-rw-r--r--src/df.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/df.c b/src/df.c
index 14f07905d..a049980ec 100644
--- a/src/df.c
+++ b/src/df.c
@@ -215,7 +215,7 @@ print_table (void)
{
size_t width = widths[field];
char *cell = table[row][field];
- if (!cell)
+ if (!cell) /* Missing type column, or mount point etc. */
continue;
/* Note the DEV_FIELD used to be displayed on it's own line
@@ -227,9 +227,9 @@ print_table (void)
fputs (cell, stdout);
else
{
- cell = ambsalign (table[row][field], &width,
- alignments[field], MBA_UNIBYTE_FALLBACK);
- fputs (cell, stdout);
+ cell = ambsalign (cell, &width, alignments[field], 0);
+ /* When ambsalign fails, output unaligned data. */
+ fputs (cell ? cell : table[row][field], stdout);
free (cell);
}
IF_LINT (free (table[row][field]));