len is not updated which leade to the function to revert
Vulnerability Detail
in the function removeAsset there is loop which is used to removes the locations from the assets but when doing it it is using len to subtract and update the location but since len is only updated on line 470 before the loop when the loop get executed the line 472 will revert if the loop is executed for the second times because it will try to accesses len -1 which is not in the range so because of that it will revert
for example lets say asset.locations.length; is 10 (len =10) so the first loop will be executed and asset.locations.length; will be 9 but len is not updated so when it came to the second one on line 472 asset.locations[i] = asset.locations[len - 1]; will revert because on the second loop asset.locations.length is 9 and since we never updated the len variable it is not and it is trying to subtract 10 -1 which is 9 and trying to access which is not in the range so due to that it will revert
jah
high
the function removeassest will not work
Summary
len is not updated which leade to the function to revert
Vulnerability Detail
in the function removeAsset there is loop which is used to removes the locations from the assets but when doing it it is using len to subtract and update the location but since len is only updated on line 470 before the loop when the loop get executed the line 472 will revert if the loop is executed for the second times because it will try to accesses len -1 which is not in the range so because of that it will revert for example lets say asset.locations.length; is 10 (len =10) so the first loop will be executed and asset.locations.length; will be 9 but len is not updated so when it came to the second one on line 472
asset.locations[i] = asset.locations[len - 1];
will revert because on the second loop asset.locations.length is 9 and since we never updated the len variable it is not and it is trying to subtract 10 -1 which is 9 and trying to access which is not in the range so due to that it will revertImpact
we cant remove assests
Code Snippet
https://github.com/sherlock-audit/2023-11-olympus/blob/main/bophades/src/modules/TRSRY/OlympusTreasury.sol#L470
Tool used
Manual Review
Recommendation
update the len variable inside the loop
Duplicate of #151