trailer: handle NULL value when parsing trailer-specific config
commit1b274c98341ef17f3bbfe80f603f629e7c950668
authorJeff King <peff@peff.net>
Thu, 7 Dec 2023 07:11:32 +0000 (7 02:11 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Dec 2023 23:24:47 +0000 (9 08:24 +0900)
tree77116aa5747296a1210b131c46184992133c9119
parent34b1a0d320e3a1531997d6681bacffbe9da7a046
trailer: handle NULL value when parsing trailer-specific config

When parsing the "key", "command", and "cmd" trailer config, we just
make a copy of the value string.  If we see an implicit bool like:

  [trailer "foo"]
  key

we'll segfault trying to copy a NULL pointer. We can fix this with the
usual config_error_nonbool() check.

I split this out from the other vanilla cases, because at first glance
it looks like a better fix here would be to move the NULL check out of
the switch statement. But it would change the behavior of other keys
like trailer.*.ifExists, where an implicit bool is interpreted as
EXISTS_DEFAULT.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trailer.c