fix: setSponsorFieldU32 silently clamps to 0 on underflow instead of failing

This commit is contained in:
tequ
2026-04-30 10:05:28 +09:00
committed by Oleksandr
parent 688e568e39
commit d057f07d0e

View File

@@ -411,7 +411,13 @@ SponsorshipTransfer::doApply()
auto const setSponsorFieldU32 = [](auto const& sle, auto const& field, auto const& delta) {
int32_t const newValue = static_cast<int32_t>(sle->getFieldU32(field)) + delta;
if (newValue <= 0)
if (newValue < 0)
{
UNREACHABLE("xrpl::SponsorshipTransfer::doApply : Invalid sponsor field value");
return;
}
else if (newValue == 0)
{
sle->makeFieldAbsent(field);
}