From a77aa50ae181ab5789a7e253ce56ec8c736bfd22 Mon Sep 17 00:00:00 2001 From: Chandra Pratap Date: Tue, 17 Jun 2025 06:56:30 +0000 Subject: [PATCH] plugins/libplugin-pay: Add a check for NaN values Changelog-Fixed: Due to the imprecision of `htlc_max`'s type (`fp16_t`), `capacity_bias()` can return `NaN` in some cases. This leads to a runtime error when compiled with UBSan. Add a check against it. --- plugins/libplugin-pay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index b296b87d7..5409e00eb 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -783,7 +783,7 @@ static u64 route_score(struct amount_msat fee, */ score = (capacity_bias(global_gossmap, c, dir, total) + 1) * msat.millisatoshis; /* Raw: Weird math */ - if (score > 0xFFFFFFFF) + if (score != score || score > 0xFFFFFFFF) return 0xFFFFFFFF; /* Cast unnecessary, but be explicit! */