From 1da977a04cc57dd5ecd987328eb34c11bd19dda4 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 27 Jul 2020 16:00:26 +0200 Subject: [PATCH] db: Guard against accessing NULL partid and total_msat These were spamming my logs and could result in misleading results being returned on `listpays` and `listsendpays`. --- wallet/wallet.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index 92ff7b8b6..bbbe43644 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -2749,8 +2749,16 @@ static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx, else payment->failonion = NULL; - db_column_amount_msat(stmt, 14, &payment->total_msat); - payment->partid = db_column_u64(stmt, 15); + if (!db_column_is_null(stmt, 14)) + db_column_amount_msat(stmt, 14, &payment->total_msat); + else + payment->total_msat = AMOUNT_MSAT(0); + + if (!db_column_is_null(stmt, 15)) + payment->partid = db_column_u64(stmt, 15); + else + payment->partid = 0; + return payment; }