Skip to content

Commit 3b54847

Browse files
committed
paymod: Do not assume that parsing the waitsendpay result succeeds
Suggested-by: ZmnSCPxj Signed-off-by: Christian Decker Reference: #3846
1 parent 2788883 commit 3b54847

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugins/libplugin-pay.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,13 @@ static void channel_hints_update(struct payment *root,
627627
static void payment_result_infer(struct route_hop *route,
628628
struct payment_result *r)
629629
{
630-
int i, len = tal_count(route);
630+
int i, len;
631+
assert(r != NULL);
632+
631633
if (r->code == 0 || r->erring_index == NULL || route == NULL)
632634
return;
633635

636+
len = tal_count(route);
634637
i = *r->erring_index;
635638
assert(i <= len);
636639

@@ -659,13 +662,14 @@ payment_waitsendpay_finished(struct command *cmd, const char *buffer,
659662
assert(p->route != NULL);
660663

661664
p->result = tal_sendpay_result_from_json(p, buffer, toks);
662-
payment_result_infer(p->route, p->result);
663665

664666
if (p->result == NULL)
665667
plugin_err(
666668
p->plugin, "Unable to parse `waitsendpay` result: %.*s",
667669
json_tok_full_len(toks), json_tok_full(buffer, toks));
668670

671+
payment_result_infer(p->route, p->result);
672+
669673
if (p->result->state == PAYMENT_COMPLETE) {
670674
payment_set_step(p, PAYMENT_STEP_SUCCESS);
671675
p->end_time = time_now();

0 commit comments

Comments
 (0)