Skip to content

Commit a77aa50

Browse files
Chandra Prataprustyrussell
authored andcommitted
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.
1 parent 5365b44 commit a77aa50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugins/libplugin-pay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static u64 route_score(struct amount_msat fee,
783783
*/
784784
score = (capacity_bias(global_gossmap, c, dir, total) + 1)
785785
* msat.millisatoshis; /* Raw: Weird math */
786-
if (score > 0xFFFFFFFF)
786+
if (score != score || score > 0xFFFFFFFF)
787787
return 0xFFFFFFFF;
788788

789789
/* Cast unnecessary, but be explicit! */

0 commit comments

Comments
 (0)