diff options
author | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2020-10-30 16:55:30 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-11-13 13:03:28 +0000 |
commit | e5c272423d1bba2825086b82fd97499237a6fa4b (patch) | |
tree | 8686e1b4282ea69401c2f28481a9e9365604d10f | |
parent | 88c8df4eab81316bc055c8be82b0febc70330dbe (diff) | |
download | qtwayland-e5c272423d1bba2825086b82fd97499237a6fa4b.tar.gz |
Scanner: Avoid accessing dangling pointers in destroy_func()
Usually, the object associated with the resource gets destroyed in the
destroy_resource() function.
Therefore, we need to double-check that the object is still alive before
trying to reset its m_resource.
Change-Id: I26408228f58919db17eb29584a1cbd4a9427d25c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 735164b5c2a2637a8d53a8803a2401e4ef477ff0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qtwaylandscanner/qtwaylandscanner.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 1d635f06..e2f87bbd 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -814,7 +814,9 @@ bool Scanner::process() printf(" if (Q_LIKELY(that)) {\n"); printf(" that->m_resource_map.remove(resource->client(), resource);\n"); printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped); - printf(" if (that->m_resource == resource)\n"); + printf("\n"); + printf(" that = resource->%s_object;\n", interfaceNameStripped); + printf(" if (that && that->m_resource == resource)\n"); printf(" that->m_resource = nullptr;\n"); printf(" }\n"); printf(" delete resource;\n"); |