summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2024-08-06 20:17:23 +0200
committerGitHub <noreply@github.com>2024-08-06 18:17:23 +0000
commita985e16832f86cbc42eb6488e6f9fc2a9eff7dc7 (patch)
tree0c81a3a861c44d6b838db07f6620fe7a1447afbd /src
parent1c3578c7e28d9fced48a756546c07a2acb26bdcc (diff)
downloadbinaryen-a985e16832f86cbc42eb6488e6f9fc2a9eff7dc7.tar.gz
binaryen-a985e16832f86cbc42eb6488e6f9fc2a9eff7dc7.tar.bz2
binaryen-a985e16832f86cbc42eb6488e6f9fc2a9eff7dc7.zip
[Source maps] Handle single-segment entries in source map header decoder (#6794)
Single-segment mappings were already handled in readNextDebugLocation, but not in readSourceMapHeader.
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-binary.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 779f1fd6f..574e13aa2 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2941,13 +2941,20 @@ void WasmBinaryReader::readSourceMapHeader() {
// investigation (if it does, it will assert in readBase64VLQ, so it
// would not be a silent error at least).
uint32_t position = readBase64VLQ(*sourceMap);
- uint32_t fileIndex = readBase64VLQ(*sourceMap);
- uint32_t lineNumber =
- readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number
- uint32_t columnNumber = readBase64VLQ(*sourceMap);
nextDebugPos = position;
- nextDebugLocation = {fileIndex, lineNumber, columnNumber};
- nextDebugLocationHasDebugInfo = true;
+
+ auto peek = sourceMap->peek();
+ if (peek == ',' || peek == '\"') {
+ // This is a 1-length entry, so the next location has no debug info.
+ nextDebugLocationHasDebugInfo = false;
+ } else {
+ uint32_t fileIndex = readBase64VLQ(*sourceMap);
+ uint32_t lineNumber =
+ readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number
+ uint32_t columnNumber = readBase64VLQ(*sourceMap);
+ nextDebugLocation = {fileIndex, lineNumber, columnNumber};
+ nextDebugLocationHasDebugInfo = true;
+ }
}
void WasmBinaryReader::readNextDebugLocation() {