File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 2727#include < utility>
2828#include < vector>
2929
30+ #include " src/common/wasm_util.h"
31+
3032#include " WAVM/IR/Module.h"
3133#include " WAVM/IR/Operators.h"
3234#include " WAVM/IR/Types.h"
@@ -301,19 +303,18 @@ bool Wavm::load(const std::string &code, bool allow_precompiled) {
301303 return false ;
302304 }
303305 getAbiVersion (); // Cache ABI version.
304- const CustomSection *precompiled_object_section = nullptr ;
306+ std::string_view precompiled = {} ;
305307 if (allow_precompiled) {
306- for (const CustomSection &customSection : ir_module_.customSections ) {
307- if (customSection.name == getPrecompiledSectionName ()) {
308- precompiled_object_section = &customSection;
309- break ;
310- }
308+ if (!common::BytecodeUtil::getCustomSection (code, getPrecompiledSectionName (), precompiled)) {
309+ fail (FailState::UnableToInitializeCode, " Failed to parse corrupted Wasm module" );
310+ return false ;
311311 }
312312 }
313- if (!precompiled_object_section ) {
313+ if (precompiled. empty () ) {
314314 module_ = WAVM::Runtime::compileModule (ir_module_);
315315 } else {
316- module_ = WAVM::Runtime::loadPrecompiledModule (ir_module_, precompiled_object_section->data );
316+ module_ = WAVM::Runtime::loadPrecompiledModule (
317+ ir_module_, {precompiled.data (), precompiled.data () + precompiled.size ()});
317318 }
318319 return true ;
319320}
You can’t perform that action at this time.
0 commit comments