Skip to content

Commit 1deba1c

Browse files
committed
plugins/pay: handle case where amount_msat is 'null'.
Deprecated, but this can happen: ``` ==1578== Conditional jump or move depends on uninitialised value(s) ==1578== at 0x12B30E: amount_msat_add (amount.c:224) ==1578== by 0x11270B: add_amount_sent (pay.c:1734) ==1578== by 0x112D89: listsendpays_done (pay.c:1831) ==1578== by 0x114F4B: handle_rpc_reply (libplugin.c:555) ==1578== by 0x115704: rpc_read_response_one (libplugin.c:685) ==1578== by 0x115821: rpc_conn_read_response (libplugin.c:705) ==1578== by 0x148E40: next_plan (io.c:59) ==1578== by 0x1499BD: do_plan (io.c:407) ==1578== by 0x1499FB: io_ready (io.c:417) ==1578== by 0x14BBC1: io_loop (poll.c:445) ==1578== by 0x117A82: plugin_main (libplugin.c:1322) ==1578== by 0x113ABC: main (pay.c:2096) ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent dcf45b4 commit 1deba1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/pay.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,8 @@ static void add_amount_sent(struct plugin *p,
17191719

17201720
/* If this is an unannotated partial payment we drop out estimate for
17211721
* all parts. */
1722-
if (msattok == NULL) {
1722+
/* FIXME: with deprecated_apis, amount_msat can be 'null' */
1723+
if (msattok == NULL || !json_to_msat(buf, msattok, &recv)) {
17231724
mpp->amount = tal_free(mpp->amount);
17241725
return;
17251726
}
@@ -1730,7 +1731,6 @@ static void add_amount_sent(struct plugin *p,
17301731
if (mpp->amount == NULL)
17311732
return;
17321733

1733-
json_to_msat(buf, msattok, &recv);
17341734
if (!amount_msat_add(mpp->amount, *mpp->amount, recv))
17351735
plugin_log(p, LOG_BROKEN,
17361736
"Cannot add amount_msat for %s: %s + %s",

0 commit comments

Comments
 (0)