mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restrict size for dynamic memory array creation.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
contract C {
|
||||
function f() public returns (uint256) {
|
||||
uint256 l = 2**256 / 32;
|
||||
// This used to work without causing an error.
|
||||
uint256[] memory x = new uint256[](l);
|
||||
uint256[] memory y = new uint256[](1);
|
||||
x[1] = 42;
|
||||
// This used to overwrite the value written above.
|
||||
y[0] = 23;
|
||||
return x[1];
|
||||
}
|
||||
function g() public returns (uint256) {
|
||||
uint256 l = 2**256 / 2 + 1;
|
||||
// This used to work without causing an error.
|
||||
uint16[] memory x = new uint16[](l);
|
||||
uint16[] memory y = new uint16[](1);
|
||||
x[2] = 42;
|
||||
// This used to overwrite the value written above.
|
||||
y[0] = 23;
|
||||
return x[2];
|
||||
}}
|
||||
// ----
|
||||
// f() -> FAILURE
|
||||
// g() -> FAILURE
|
||||
Reference in New Issue
Block a user