From 1471c2c6b29d297cb459f12a161107749d9075ec Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 29 Jul 2021 19:01:24 +0200 Subject: [PATCH 1/2] Fix potentially unitialized padded_code --- lib/evmone/baseline.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index b28e365014..c6720f2da6 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -35,7 +35,8 @@ CodeAnalysis analyze(const uint8_t* code, size_t code_size) // Using "raw" new operator instead of std::make_unique() to get uninitialized array. std::unique_ptr padded_code{new uint8_t[i + 1]}; // +1 for the final STOP. std::copy_n(code, code_size, padded_code.get()); - padded_code[i] = OP_STOP; // Set final STOP at the code end. + // Set final STOP at the code end. + std::fill_n(padded_code.get() + code_size, i + 1 - code_size, OP_STOP); // TODO: Using fixed-size padding of 33, the padded code buffer and jumpdest bitmap can be // created with single allocation. From dc32466d5921d090af7cdf4864d1a2c84a7fe7e0 Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 29 Jul 2021 19:14:01 +0200 Subject: [PATCH 2/2] Fix MSVC warning --- lib/evmone/baseline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index c6720f2da6..a0db79d3a3 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -36,7 +36,7 @@ CodeAnalysis analyze(const uint8_t* code, size_t code_size) std::unique_ptr padded_code{new uint8_t[i + 1]}; // +1 for the final STOP. std::copy_n(code, code_size, padded_code.get()); // Set final STOP at the code end. - std::fill_n(padded_code.get() + code_size, i + 1 - code_size, OP_STOP); + std::fill_n(padded_code.get() + code_size, i + 1 - code_size, uint8_t{OP_STOP}); // TODO: Using fixed-size padding of 33, the padded code buffer and jumpdest bitmap can be // created with single allocation.