Make sure !empty() before calling String::front().
Reviewers: howard.hinnant
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D9954
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@238263 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/cxa_demangle.cpp b/src/cxa_demangle.cpp
index 3bf3af9..d80843e 100644
--- a/src/cxa_demangle.cpp
+++ b/src/cxa_demangle.cpp
@@ -1671,7 +1671,7 @@
auto func = std::move(db.names.back());
db.names.pop_back();
auto class_type = std::move(db.names.back());
- if (func.second.front() == '(')
+ if (!func.second.empty() && func.second.front() == '(')
{
db.names.back().first = std::move(func.first) + "(" + class_type.move_full() + "::*";
db.names.back().second = ")" + std::move(func.second);
@@ -2018,7 +2018,8 @@
db.names[k].first += " (";
db.names[k].second.insert(0, ")");
}
- else if (db.names[k].second.front() == '(')
+ else if (!db.names[k].second.empty() &&
+ db.names[k].second.front() == '(')
{
db.names[k].first += "(";
db.names[k].second.insert(0, ")");
@@ -2045,7 +2046,8 @@
db.names[k].first += " (";
db.names[k].second.insert(0, ")");
}
- else if (db.names[k].second.front() == '(')
+ else if (!db.names[k].second.empty() &&
+ db.names[k].second.front() == '(')
{
db.names[k].first += "(";
db.names[k].second.insert(0, ")");
@@ -2079,7 +2081,8 @@
db.names[k].first += " (";
db.names[k].second.insert(0, ")");
}
- else if (db.names[k].second.front() == '(')
+ else if (!db.names[k].second.empty() &&
+ db.names[k].second.front() == '(')
{
db.names[k].first += "(";
db.names[k].second.insert(0, ")");