# `_listing` mapping not deleted when calling `Listings::reserve` can lead to a token being sold when it shouldn't be for sale

Listings::reserve fails to delete the original _listing mapping, so after unlockProtectedListing without withdrawal the stale listing lets a third party buy the token, double-paying the seller.

- Payout: Audit contest
- Severity: high
- Program: Flayer
- Found by: 0x37
- Disclosed: 2024-08-06
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/252
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-flayer%3AH-9
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Listings / ProtectedListings contracts (Solidity)
**Root cause:** Listings::reserve creates a protected listing but does not delete the pre-existing _listings[_collection][_tokenId] entry, so the old listing reactivates once the protected listing is unlocked without withdrawal.
**Steps:**
1. User A creates a listing via `Listings::createListings` for tokenId 1199.
2. User B calls `Listings::reserve(collection, tokenId, 0.2 ether)`; the original `_listings` entry is not deleted.
3. User B calls `ProtectedListings::unlockProtectedListing(collection, tokenId, false)` so the NFT stays in the Locker.
4. User C calls `Listings::fillListings` with the stale listing data and receives the NFT.
5. Observe: User A paid twice, User B paid but got no NFT, `listingCount` decremented twice (unchecked underflow).
**How found:** Code reading of Listings::reserve vs _fillListing/cancelListing: noticed reserve never deletes _listings entry, then reasoned that unlockProtectedListing with _withdraw=false leaves the NFT in the Locker where the stale listing becomes fillable.
**Exploitation:** Attacker (User C) monitors for tokens whose protected listing was unlocked without withdrawal, then calls fillListings against the stale listing to buy the NFT at the old price while the original seller is paid again and the reserve payer loses funds.
**Escalation:** Repeated listingCount decrements in unchecked block can underflow, corrupting hasListings used by CollectionShutdown to sunset collections with live listings.
**Insight:** When a function transitions a token between listing types (e.g. normal -> protected), check that the old state mapping is explicitly deleted; a shadowing read path (protected checked first) can mask the stale entry until the new state is removed.

