The claimSingleReward function in the MysteryBox contract deletes a reward from an array without reordering or compacting the array. This results in gaps within the array, leading to potential inefficiencies and complications in data management.
The function uses the delete keyword to remove an element from the rewardsOwned array, which sets the element to its default value but does not reduce the array's length or reorder the remaining elements.
The line delete rewardsOwned[msg.sender][_index]; is where the element is set to its default value, creating a gap in the array.
Gaps in the array can lead to incorrect assumptions about the data structure, potentially causing errors in logic that processes the array.
Manual review
Instead of using delete, replace the element to be removed with the last element in the array and then reduce the array's length. This approach maintains a contiguous array without gaps.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.