Skip to content

Commit

Permalink
Don't try to read SLE with key 0 from the ledger:
Browse files Browse the repository at this point in the history
* May resolve #4341
  • Loading branch information
ximinez committed Nov 28, 2022
1 parent ebbf4b6 commit 0617d6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)
-> std::pair<std::shared_ptr<const SLE>, TER> {
if (id)
{
if (id->isZero())
return {nullptr, tecOBJECT_NOT_FOUND};

auto offerSLE = ctx.view.read(keylet::nftoffer(*id));

if (!offerSLE)
Expand Down
12 changes: 12 additions & 0 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,12 @@ class NFToken_test : public beast::unit_test::suite
//----------------------------------------------------------------------
// preclaim

// The buy offer must be non-zero.
env(token::acceptBuyOffer(buyer, beast::zero),
ter(tecOBJECT_NOT_FOUND));
env.close();
BEAST_EXPECT(ownerCount(env, buyer) == 0);

// The buy offer must be present in the ledger.
uint256 const missingOfferIndex = keylet::nftoffer(alice, 1).key;
env(token::acceptBuyOffer(buyer, missingOfferIndex),
Expand All @@ -1142,6 +1148,12 @@ class NFToken_test : public beast::unit_test::suite
env.close();
BEAST_EXPECT(ownerCount(env, buyer) == 0);

// The sell offer must be non-zero.
env(token::acceptSellOffer(buyer, beast::zero),
ter(tecOBJECT_NOT_FOUND));
env.close();
BEAST_EXPECT(ownerCount(env, buyer) == 0);

// The sell offer must be present in the ledger.
env(token::acceptSellOffer(buyer, missingOfferIndex),
ter(tecOBJECT_NOT_FOUND));
Expand Down

0 comments on commit 0617d6e

Please sign in to comment.