Skip to content

Commit

Permalink
mitigation: fix reentry (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 authored Aug 12, 2024
1 parent 8d0e283 commit 403792e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/NFTMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ contract NFTMint is Ownable {
numOrdersToFill == 0 ? orders.length : Math.min(orders.length, nextOrderIdToFill_ + numOrdersToFill);

while (nextOrderIdToFill_ < finalNextOrderToFill) {
Order storage currentOrder = orders[nextOrderIdToFill_];
Order memory currentOrder = orders[nextOrderIdToFill_];
if (msg.sender != owner() && currentOrder.orderTimestamp + 1 hours > block.timestamp) {
// Only the owner can fill orders that are less than 1 hour old
break;
Expand Down Expand Up @@ -287,10 +287,10 @@ contract NFTMint is Ownable {
mstore(amounts, numNonZero)
}

// If the mint fails with 500_000 gas, the order is still marked as filled.
try currentOrder.mint.mintBatch{ gas: 500_000 }(currentOrder.to, ids, amounts) { } catch { }
delete orders[nextOrderIdToFill_];
nextOrderIdToFill_++;
// If the mint fails with 500_000 gas, the order is still marked as filled.
try currentOrder.mint.mintBatch{ gas: 500_000 }(currentOrder.to, ids, amounts) { } catch { }
}

nextOrderIdToFill = uint96(nextOrderIdToFill_);
Expand Down

0 comments on commit 403792e

Please sign in to comment.