lightningd: don't allocate to print node_id for logging.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-05-08 12:20:47 +09:30
parent b387b26cb3
commit 2d7f268465

View File

@@ -207,7 +207,7 @@ static void log_to_files(const char *log_prefix,
struct log_file **log_files)
{
char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")];
char *entry, *nodestr;
char *entry, nodestr[hex_str_size(PUBKEY_CMPR_LEN)];
bool filtered;
if (print_timestamps) {
@@ -218,9 +218,10 @@ static void log_to_files(const char *log_prefix,
tstamp[0] = '\0';
if (node_id)
nodestr = fmt_node_id(tmpctx, node_id);
hex_encode(node_id->k, sizeof(node_id->k),
nodestr, sizeof(nodestr));
else
nodestr = "";
nodestr[0] = '\0';
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
const char *dir = level == LOG_IO_IN ? "[IN]" : "[OUT]";
char *hex = tal_hexstr(NULL, io, io_len);