summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2020-01-20 19:05:46 +0100
committerAleix Pol <aleixpol@kde.org>2020-02-14 13:47:54 +0100
commitcfc4043626e05649e51607a92ceb87d31e0d1b06 (patch)
tree18a3994f3aaa514c47b51ffbeedec4cd5687b2ae
parente21230a3b8b4aca50121c373a6ffea770807d4a0 (diff)
Make generated files more resilient to crashesv5.15.0-beta1
If m_resource is not initialized when calling a send_* method it will simply crash. This change checks for it beforehand so we get a warning instead. Change-Id: I601f9070a35a1b3e595567991f7e54e9a6572c2d Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 05f00bee..3cecb5bc 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -906,6 +906,11 @@ bool Scanner::process()
printEvent(e);
printf("\n");
printf(" {\n");
+ printf(" Q_ASSERT_X(m_resource, \"%s::%s\", \"Uninitialised resource\");\n", interfaceName, e.name.constData());
+ printf(" if (Q_UNLIKELY(!m_resource)) {\n");
+ printf(" qWarning(\"could not call %s::%s as it's not initialised\");\n", interfaceName, e.name.constData());
+ printf(" return;\n");
+ printf(" }\n");
printf(" send_%s(\n", e.name.constData());
printf(" m_resource->handle");
for (const WaylandArgument &a : e.arguments) {