@@ -268,7 +268,7 @@ bool V8::load(const std::string &code, bool allow_precompiled) {
268268 if (allow_precompiled) {
269269 const auto section_name = getPrecompiledSectionName ();
270270 if (!section_name.empty ()) {
271- string_view precompiled = {};
271+ std:: string_view precompiled = {};
272272 if (!common::WasmUtil::getCustomSection (source_begin, source_end, section_name,
273273 precompiled)) {
274274 fail (FailState::UnableToInitializeCode, " Failed to parse corrupted Wasm module" );
@@ -289,11 +289,16 @@ bool V8::load(const std::string &code, bool allow_precompiled) {
289289 }
290290
291291 if (!module_) {
292- const std::vector<char > stripped =
293- common::WasmUtil::getStrippedSource (source_begin, source_end);
294- module_ = wasm::Module::make (
295- store_.get (),
296- stripped.empty () ? source_ : wasm::vec<byte_t >::make (stripped.size (), stripped.data ()));
292+ std::vector<char > stripped;
293+ if (!common::WasmUtil::getStrippedSource (source_begin, source_end, stripped)) {
294+ fail (FailState::UnableToInitializeCode, " Failed to parse corrupted Wasm module" );
295+ };
296+ if (stripped.empty ()) {
297+ module_ = wasm::Module::make (store_.get (), source_);
298+ } else {
299+ auto vec = wasm::vec<byte_t >::make (stripped.size (), stripped.data ());
300+ module_ = wasm::Module::make (store_.get (), vec);
301+ }
297302 }
298303
299304 if (module_) {
0 commit comments