Re: git column fails (or crashes) if padding is negative
- From
Kristoffer Haugsbakk <code@khaugsbakk.name>
- Date
- Feb 11, 2024, 17:08 UTC
- Message-ID
- <3380df68-83fb-417b-a490-71614edc342f@app.fastmail.com>
- In-Reply-To
- <xmqqttmhfrko.fsf@gitster.g>
On Fri, Feb 9, 2024, at 18:57, Junio C Hamano wrote:
Show 16 quoted lines
> builtin/column.c | 2 ++ > column.c | 4 ++-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > […] > diff --git c/column.c w/column.c > index ff2f0abf39..9cc703832a 100644 > --- c/column.c > +++ w/column.c > @@ -189,7 +189,7 @@ void print_columns(const struct string_list *list, > unsigned int colopts, > memset(&nopts, 0, sizeof(nopts)); > nopts.indent = opts && opts->indent ? opts->indent : ""; > nopts.nl = opts && opts->nl ? opts->nl : "\n"; > - nopts.padding = opts ? opts->padding : 1; > + nopts.padding = (opts && 0 < opts->padding) ? opts->padding : 1;
If these two are meant to check the same condition as in `builtin/column.c`, shouldn’t it be `0 <= opts->padding`?
Show 13 quoted lines
> nopts.width = opts && opts->width ? opts->width : term_columns() - 1;
> if (!column_active(colopts)) {
> display_plain(list, "", "\n");
> @@ -373,7 +373,7 @@ int run_column_filter(int colopts, const struct
> column_options *opts)
> strvec_pushf(argv, "--width=%d", opts->width);
> if (opts && opts->indent)
> strvec_pushf(argv, "--indent=%s", opts->indent);
> - if (opts && opts->padding)
> + if (opts && 0 < opts->padding)
> strvec_pushf(argv, "--padding=%d", opts->padding);
>
> fflush(stdout);-- Kristoffer Haugsbakk