Fix crash when passing empty strings to bytes.concat()

This commit is contained in:
Kamil Śliwak
2021-06-29 13:52:01 +02:00
parent 7bce83e7c4
commit fa3696878b
6 changed files with 36 additions and 2 deletions
@@ -0,0 +1,27 @@
contract C {
function f() public returns (bytes memory) {
bytes memory b = "";
return bytes.concat(
bytes.concat(b),
bytes.concat(b, b),
bytes.concat("", b),
bytes.concat(b, "")
);
}
function g() public returns (bytes memory) {
return bytes.concat("", "abc", hex"", "abc", unicode"");
}
function h() public returns (bytes memory) {
bytes memory b = "";
return bytes.concat(b, "abc", b, "abc", b);
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
// ----
// f() -> 0x20, 0
// g() -> 0x20, 6, "abcabc"
// h() -> 0x20, 6, "abcabc"
@@ -0,0 +1,6 @@
contract C {
function f() public pure {
bytes.concat(hex"", unicode"", "");
}
}
// ----