From f117c2a37b30b8a295b2cf04122c0ae1f2c26526 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 17 May 2022 13:16:50 +0200 Subject: [PATCH] ImageContainer: Fix potential use after free Found during clang-analyzer run. Change-Id: I6549403ac949650058348ccc22b2020d09ef53e0 Reviewed-by: Thomas Hartmann --- share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp index b556620c54f..38d8a282b2e 100644 --- a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp @@ -98,7 +98,8 @@ static SharedMemory *createSharedMemory(qint32 key, int byteCount) sharedMemory = new SharedMemory(QString(imageKeyTemplateString).arg(key)); bool sharedMemoryIsCreated = sharedMemory->create(byteCount); if (sharedMemoryIsCreated) { - globalSharedMemoryContainer()->insert(key, sharedMemory); + if (!globalSharedMemoryContainer()->insert(key, sharedMemory)) + return nullptr; } else { delete sharedMemory; sharedMemory = nullptr;