summaryrefslogtreecommitdiff
path: root/src/decompiler.cc
diff options
context:
space:
mode:
authorHyxogen <8938732+Hyxogen@users.noreply.github.com>2023-11-20 20:30:46 +0100
committerGitHub <noreply@github.com>2023-11-20 11:30:46 -0800
commit6367a02e9fddefb62dcb1a1a61af3d067c93ae9a (patch)
tree4dcdbf5b215aed3e4dbe035660d98e529f92bf88 /src/decompiler.cc
parent8ad63cc00617690f9552b794cef220d26cc46f80 (diff)
downloadwabt-6367a02e9fddefb62dcb1a1a61af3d067c93ae9a.tar.gz
wabt-6367a02e9fddefb62dcb1a1a61af3d067c93ae9a.tar.bz2
wabt-6367a02e9fddefb62dcb1a1a61af3d067c93ae9a.zip
decompiler.cc: fix vector oob when if has empty then (#2334)
Diffstat (limited to 'src/decompiler.cc')
-rw-r--r--src/decompiler.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/decompiler.cc b/src/decompiler.cc
index 3eab2dd0..257de836 100644
--- a/src/decompiler.cc
+++ b/src/decompiler.cc
@@ -527,7 +527,10 @@ struct Decompiler {
ifs.precedence = Precedence::If;
return std::move(ifs);
} else {
- auto s = cat("if (", ifs.v[0], ") { ", thenp.v[0], " }");
+ auto s = cat("if (", ifs.v[0], ") {");
+ if (!thenp.v.empty())
+ s += cat(" ", thenp.v[0], " ");
+ s += "}";
if (elsep)
s += cat(" else { ", elsep->v[0], " }");
return Value{{std::move(s)}, Precedence::If};