Skip to content

Commit cefe656

Browse files
committed
Check Wasm header
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent c5b123c commit cefe656

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/common/wasm_util.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ bool BytecodeUtil::checkWasmHeader(std::string_view bytecode) {
2525

2626
bool BytecodeUtil::getCustomSection(std::string_view bytecode, std::string_view name,
2727
std::string_view &ret) {
28+
// Check Wasm header.
29+
if (!checkWasmHeader(bytecode)) {
30+
return false;
31+
}
32+
2833
// Skip the Wasm header.
2934
const char *pos = bytecode.data() + 8;
3035
const char *end = bytecode.data() + bytecode.size();
@@ -107,6 +112,11 @@ bool BytecodeUtil::getFunctionNameIndex(std::string_view bytecode,
107112
}
108113

109114
bool BytecodeUtil::getStrippedSource(std::string_view bytecode, std::string &ret) {
115+
// Check Wasm header.
116+
if (!checkWasmHeader(bytecode)) {
117+
return false;
118+
}
119+
110120
// Skip the Wasm header.
111121
const char *pos = bytecode.data() + 8;
112122
const char *end = bytecode.data() + bytecode.size();

0 commit comments

Comments
 (0)