summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2018-11-14 23:09:30 -0800
committerThomas Lively <7121787+tlively@users.noreply.github.com>2018-11-15 10:02:17 -0800
commit892d2d747883aca132d2eb4e3ba5a6b261f944af (patch)
tree9a8e1c55d6c989fb11404942a6e15e44278286d1 /src
parentc1e75fe5c79a5e47c0c861fe19f78d8aa700bd16 (diff)
downloadbinaryen-892d2d747883aca132d2eb4e3ba5a6b261f944af.tar.gz
binaryen-892d2d747883aca132d2eb4e3ba5a6b261f944af.tar.bz2
binaryen-892d2d747883aca132d2eb4e3ba5a6b261f944af.zip
Avoid segfault when printing null name
`strpbrk` segfaults when `name.str` is nullptr, so check first.
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 64cea8bb2..14ef584be 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -36,10 +36,10 @@ static bool isFullForced() {
static std::ostream& printName(Name name, std::ostream& o) {
// we need to quote names if they have tricky chars
- if (strpbrk(name.str, "()")) {
- o << '"' << name << '"';
- } else {
+ if (!name.str || !strpbrk(name.str, "()")) {
o << name;
+ } else {
+ o << '"' << name << '"';
}
return o;
}