Closed JimmyShi22 closed 1 year ago
Hi Jimmy, Thanks for your PR, I think the bus can be fixed by adding a require above line7,
require(size > 0, "Wrong array size");
Actually, j is the number of right index of one array, it should be bigger than 0.
So happy can get the reply!
The problem is that, I call the function by sort(4, xxx) or sort(100, xxx), but get revert.
After a long caculation with my pen, i found that in line 28, if j is 0, j-- will get a big uint. So that reqire(size > 0) may not fix this problem.
Example: sort(4, xxxx) will be failed. Because in line 28, j is 0, j-- will get a big uint. This will leads to a failure.