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.
This commit is contained in:
Chandra Pratap
2025-06-17 06:56:30 +00:00
committed by Rusty Russell
parent 5365b44e1b
commit a77aa50ae1

View File

@@ -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! */