From 96d260b787032169fca4247fb3bad3cf9596db54 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 28 Aug 2020 12:00:57 +0930 Subject: [PATCH] wallet: fix reference to potentially-undefined variable. If all is set, diff may not be: ==1230518== Use of uninitialised value of size 8 ==1230518== at 0x4C5781B: _itoa_word (_itoa.c:179) ==1230518== by 0x4C736F4: __vfprintf_internal (vfprintf-internal.c:1687) ==1230518== by 0x4C88119: __vsnprintf_internal (vsnprintf.c:114) ==1230518== by 0x1D44B6: do_vfmt (str.c:66) ==1230518== by 0x1D45A0: tal_vfmt_ (str.c:92) ==1230518== by 0x1D4401: tal_fmt_ (str.c:44) ==1230518== by 0x15D30F: fmt_amount_sat (amount.c:60) ==1230518== by 0x15D338: fmt_amount_sat_ (amount.c:62) ==1230518== by 0x178C45: type_to_string_ (type_to_string.c:35) ==1230518== by 0x1B8F75: json_fundpsbt (reservation.c:394) ==1230518== by 0x12D0EC: command_exec (jsonrpc.c:602) ==1230518== by 0x12D598: rpc_command_hook_callback (jsonrpc.c:712) Signed-off-by: Rusty Russell --- wallet/reservation.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wallet/reservation.c b/wallet/reservation.c index 5b3a764b5..2e0d02c95 100644 --- a/wallet/reservation.c +++ b/wallet/reservation.c @@ -324,9 +324,10 @@ static struct command_result *json_fundpsbt(struct command *cmd, struct amount_sat, amount), tal_count(utxos), - type_to_string(tmpctx, - struct amount_sat, - &diff)); + all ? "all" + : type_to_string(tmpctx, + struct amount_sat, + &diff)); } if (all) {