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>
bb10
Volker Hilsheimer 2021-03-01 11:31:11 +01:00
parent 3875575ab6
commit 3ae09debab
1 changed files with 4 additions and 0 deletions

View File

@ -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