ooibc88 / blockbench

BLOCKBENCH: A Framework for Analyzing Private Blockchains. Blockbench contains workloads for measuring the data processing performance, and workloads for understanding the performance of different layers of Blockchain systems.
https://www.comp.nus.edu.sg/~dbsystem/fabricsharp/#/blockbench
Apache License 2.0
391 stars 174 forks source link

Fix index overflow bug #97

Closed JimmyShi22 closed 1 year ago

JimmyShi22 commented 2 years ago

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.

KunPengRen commented 2 years 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.

JimmyShi22 commented 2 years ago

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.