Description:
The removeBeneficiary()
function uses delete beneficiaries[indexToRemove]
which sets the address at that index to the zero address but doesn't actually remove the element from the array. This leaves a gap in the array, which could cause issues with array length calculations and iteration logic.
Impact:
The function does not properly remove beneficiaries, potentially affecting the inheritance distribution logic
The zero address could be considered a valid beneficiary in some operations
The beneficiaries.length
will still include deleted entries, affecting calculations like equal distribution of assets
Funds lost to zero address
Recommendation:
Implement proper array removal by swapping the element to be removed with the last element and then popping the last element:
Foundry Testing Framework
Manual Code Review
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.