shared/format-table: allocate buffer of sufficient size
This commit is contained in:
@@ -1441,7 +1441,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
_cleanup_free_ char *p = NULL;
|
||||
char *ret;
|
||||
|
||||
p = new(char, FORMAT_TIMESTAMP_MAX);
|
||||
p = new(char, d->type == TABLE_TIMESTAMP_RELATIVE ? FORMAT_TIMESTAMP_RELATIVE_MAX : FORMAT_TIMESTAMP_MAX);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
@@ -1450,7 +1450,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
else if (d->type == TABLE_TIMESTAMP_UTC)
|
||||
ret = format_timestamp_style(p, FORMAT_TIMESTAMP_MAX, d->timestamp, TIMESTAMP_UTC);
|
||||
else
|
||||
ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
|
||||
ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_RELATIVE_MAX, d->timestamp);
|
||||
if (!ret)
|
||||
return "n/a";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user