QSqlError: protect against self-assignment
Address static analyzer warning 6eb3060fd64e459b6cd5586dc561e0ba. Also make assignment from a moved-from object safe. Task-number: QTBUG-91912 Change-Id: I732dc244ac0c731a02d85e88023dbd952b9eb112 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
parent
5a2ee82f2c
commit
872f3fffbf
@ -151,9 +151,13 @@ QSqlError::QSqlError(const QSqlError& other)
|
||||
|
||||
QSqlError& QSqlError::operator=(const QSqlError& other)
|
||||
{
|
||||
if (d)
|
||||
if (&other == this)
|
||||
return *this;
|
||||
if (d && other.d)
|
||||
*d = *other.d;
|
||||
else
|
||||
else if (d)
|
||||
*d = QSqlErrorPrivate();
|
||||
else if (other.d)
|
||||
d = new QSqlErrorPrivate(*other.d);
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user