aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-08-27 13:47:55 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-08-27 14:18:26 +0200
commita672adaee34114a1697297022de9eb7237e6b7d1 (patch)
tree6bd55352489ecebb5a8b16b771b5cecac7110090
parent5557b5df397265a29e406926cf6dd1a4bda561b7 (diff)
shiboken6: Fix crash when parsing adding functions with empty parameter type
Writing something like <add-function signature="foo(,,a)"/> would cause a crash. Bail out with an error instead. Pick-to: 6.1 Change-Id: I9e49cdbcd44b53e603afdcc863fa8b93a750250d Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.cpp5
-rw-r--r--sources/shiboken6/ApiExtractor/typeparser.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/sources/shiboken6/ApiExtractor/modifications.cpp b/sources/shiboken6/ApiExtractor/modifications.cpp
index f5afef124..118b511e6 100644
--- a/sources/shiboken6/ApiExtractor/modifications.cpp
+++ b/sources/shiboken6/ApiExtractor/modifications.cpp
@@ -357,8 +357,11 @@ AddedFunction::AddedFunctionPtr
for (const auto &p : params) {
TypeInfo type = p.type == QLatin1String("...")
? TypeInfo::varArgsType() : TypeParser::parse(p.type, errorMessage);
- if (!errorMessage->isEmpty())
+ if (!errorMessage->isEmpty()) {
+ errorMessage->prepend(u"Unable to parse added function "_qs + signatureIn
+ + u": "_qs);
return {};
+ }
arguments.append({type, p.name, p.defaultValue});
}
diff --git a/sources/shiboken6/ApiExtractor/typeparser.cpp b/sources/shiboken6/ApiExtractor/typeparser.cpp
index 38c556d41..fba3a8801 100644
--- a/sources/shiboken6/ApiExtractor/typeparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typeparser.cpp
@@ -307,6 +307,9 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage)
tok = scanner.nextToken();
}
- Q_ASSERT(!stack.isEmpty());
+ if (stack.isEmpty() || stack.constFirst().qualifiedName().isEmpty()) {
+ *errorMessage = u"Unable to parse type \""_qs + str + u"\"."_qs;
+ return {};
+ }
return stack.constFirst();
}