Skip to content

Commit cd2a431

Browse files
authored
show a clear error on nulls in inline strings in binary format (#1068)
* show a clear error on nulls in inline strings (which we don't support, and in general are not seen in practice, but are technically valid wasm) in binary format reading
1 parent 2d289c3 commit cd2a431

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/wasm/wasm-binary.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,11 @@ Name WasmBinaryBuilder::getInlineString() {
12411241
auto len = getU32LEB();
12421242
std::string str;
12431243
for (size_t i = 0; i < len; i++) {
1244-
str = str + char(getInt8());
1244+
auto curr = char(getInt8());
1245+
if (curr == 0) {
1246+
throw ParseException("inline string contains NULL (0). that is technically valid in wasm, but you shouldn't do it, and it's not supported in binaryen");
1247+
}
1248+
str = str + curr;
12451249
}
12461250
if (debug) std::cerr << "getInlineString: " << str << " ==>" << std::endl;
12471251
return Name(str);

0 commit comments

Comments
 (0)