lightningd: fix fatal() log message in log.

The one to stderr is fine, the log one gets corrupted, like so:

```
2022-07-24T07:20:08.6250702Z lightningd-2 2022-07-24T06:49:19.494Z **BROKEN** lightningd: Plugin '????UH??SH??8H?}?H?u?H?U?H?M?H?M?H?E?H?????' returned an invalid response to the db_write hook: (F???U
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-25 13:33:59 +09:30 committed by neil saitug
parent d0c321b43a
commit 0fd8a6492e

View file

@ -840,14 +840,20 @@ void log_backtrace_exit(void)
void fatal_vfmt(const char *fmt, va_list ap)
{
va_list ap2;
/* You are not allowed to re-use va_lists, so make a copy. */
va_copy(ap2, ap);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
if (!crashlog)
exit(1);
logv(crashlog, LOG_BROKEN, NULL, true, fmt, ap);
logv(crashlog, LOG_BROKEN, NULL, true, fmt, ap2);
abort();
/* va_copy() must be matched with va_end(), even if unreachable. */
va_end(ap2);
}
void fatal(const char *fmt, ...)