diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-01 11:31:11 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-04 19:58:44 +0100 |
commit | 3ae09debab67eecc48721481b76fa11a9f9a383c (patch) | |
tree | 9f6c85bf2e61226596dcd98dbed7e9aa18496313 /src/widgets/widgets | |
parent | 3875575ab622d8fa41cfcf3c1f7f08dfc9e755f4 (diff) |
Protect against self-assignment, plug potential memory leak
Fixes static analyzer warning f03d95823e9f1395d64501cc111f0f63
As a drive-by, plug the potential memory leak if the assigned-to
QDockAreaLayoutItem already holds a QDockAreaLayoutInfo object.
The subinfo is deleted in the destructor, QDockAreaLayoutItem
has ownership for the subinfo.
Pick-to: 6.1
Change-Id: I8546adc6fb0537078eea9dfb45d1bd9967d8d149
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 2654341505..7776ae6613 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -182,7 +182,11 @@ QSize QDockAreaLayoutItem::sizeHint() const QDockAreaLayoutItem &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other) { + if (this == &other) + return *this; + widgetItem = other.widgetItem; + delete subinfo; if (other.subinfo == nullptr) subinfo = nullptr; else |