Fix off by 1 error in codecopy (#812)

* Fix off by 1 in codecopy

* Add regression test

* Improve formatting
This commit is contained in:
Mark Mossberg 2018-03-15 16:41:29 -04:00 committed by GitHub
parent fb3938bb3e
commit eaa0e524b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -1660,7 +1660,7 @@ class EVM(Eventful):
self._consume(GCOPY * ceil32(size) // 32) self._consume(GCOPY * ceil32(size) // 32)
for i in range(size): for i in range(size):
if (code_offset + i > len(self.bytecode)): if code_offset + i >= len(self.bytecode):
self._store(mem_offset + i, 0) self._store(mem_offset + i, 0)
else: else:
self._store(mem_offset + i, Operators.ORD(self.bytecode[code_offset + i])) self._store(mem_offset + i, Operators.ORD(self.bytecode[code_offset + i]))

5
tests/binaries/780.sol Normal file
View File

@ -0,0 +1,5 @@
contract C {
function C(bool x) {
return;
}
}

View File

@ -128,7 +128,7 @@ class IntegrationTest(unittest.TestCase):
self.assertTrue(len(actual) > 100 ) self.assertTrue(len(actual) > 100 )
def test_eth_regressions(self): def test_eth_regressions(self):
contracts = [676, 678, 701, 714, 735, 760] contracts = [676, 678, 701, 714, 735, 760, 780]
for contract in contracts: for contract in contracts:
self._simple_cli_run('{}.sol'.format(contract)) self._simple_cli_run('{}.sol'.format(contract))