Skip to content

Commit

Permalink
fix: prevent existing queue elements to be overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Mar 28, 2024
1 parent 9659c19 commit 8802715
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/UnlockQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pragma solidity >=0.8.19;

library UnlockQueue {
error QueueEmpty();
error IdExists();

struct Item {
uint256 id;
Expand Down Expand Up @@ -110,6 +111,10 @@ library UnlockQueue {
uint256 tail = q._tail;
uint256 newTail = unlock.id;

if (tail != 0) {
if (q.nodes[newTail].data.id != 0) revert IdExists();
}

q.nodes[newTail].data = unlock;
q.nodes[newTail].prev = tail;

Expand Down

0 comments on commit 8802715

Please sign in to comment.