solidity icon indicating copy to clipboard operation
solidity copied to clipboard

ABICoderV2 causes execution reverted when decoder bytes to two-dimensional array

Open Subway2023 opened this issue 6 months ago • 0 comments

Environment

  • Compiler version:
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): None
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

pragma experimental ABIEncoderV2;

contract C{
    function f() public returns (uint) {
        bytes memory corrupt = abi.encode(uint(32),uint(0)); 
	uint[][2] memory decoded = abi.decode(corrupt, (uint[][2]));
    }
}

Run in remix

image

Run in geth evm

{"output":"","gasUsed":"0x3f6","error":"execution reverted"}

Analyse

If we replace uint[][2] with uint[2], the program executes normally.

Subway2023 avatar Aug 13 '24 08:08 Subway2023