Your require statement checks that pos is not equal to 0, which is a good check to ensure that you don't attempt to find the parent of the root node.
However, you might also want to check if pos is an even number (assuming the binary tree structure is zero-indexed), as odd-numbered positions should not have a left child. This additional check can further improve the safety of the function.
require(pos != 0, "Position should not be zero");
require(pos % 2 == 0, "Position should be an even number");
Lines of code
https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/MaxHeap.sol#L78
Vulnerability details
Your require statement checks that pos is not equal to 0, which is a good check to ensure that you don't attempt to find the parent of the root node. However, you might also want to check if pos is an even number (assuming the binary tree structure is zero-indexed), as odd-numbered positions should not have a left child. This additional check can further improve the safety of the function.
require(pos != 0, "Position should not be zero"); require(pos % 2 == 0, "Position should be an even number");
Assessed type
Invalid Validation