2023-05-05 15:43:57 +08:00
|
|
|
From: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
|
|
|
|
Date: Fri, 5 May 2023 07:44:32 +0000
|
|
|
|
Subject: fix deletion order in QImageReader/Writer destructors
|
|
|
|
|
2023-05-05 14:54:31 +08:00
|
|
|
Origin: upstream, commits
|
|
|
|
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f091026be1deb4b4
|
|
|
|
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=5633cb69f68ca3d3
|
|
|
|
Last-Update: 2023-02-26
|
|
|
|
|
2023-05-05 15:43:57 +08:00
|
|
|
The device would be deleted before the image format handler, and hence
|
|
|
|
be a dangling pointer that could easily cause a crash if the handler
|
|
|
|
or codec would access it on destruction, e.g. for cleanup.
|
|
|
|
---
|
|
|
|
src/gui/image/qimagereader.cpp | 6 +++---
|
|
|
|
src/gui/image/qimagewriter.cpp | 6 +++---
|
|
|
|
2 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
|
|
|
|
index 5cb7e13..1274622 100644
|
2023-05-05 14:54:31 +08:00
|
|
|
--- a/src/gui/image/qimagereader.cpp
|
|
|
|
+++ b/src/gui/image/qimagereader.cpp
|
2023-05-05 15:43:57 +08:00
|
|
|
@@ -515,9 +515,9 @@ QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq)
|
2023-05-05 14:54:31 +08:00
|
|
|
*/
|
|
|
|
QImageReaderPrivate::~QImageReaderPrivate()
|
|
|
|
{
|
|
|
|
+ delete handler;
|
|
|
|
if (deleteDevice)
|
|
|
|
delete device;
|
|
|
|
- delete handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2023-05-05 15:43:57 +08:00
|
|
|
@@ -774,12 +774,12 @@ bool QImageReader::decideFormatFromContent() const
|
2023-05-05 14:54:31 +08:00
|
|
|
*/
|
|
|
|
void QImageReader::setDevice(QIODevice *device)
|
|
|
|
{
|
|
|
|
+ delete d->handler;
|
|
|
|
+ d->handler = nullptr;
|
|
|
|
if (d->device && d->deleteDevice)
|
|
|
|
delete d->device;
|
|
|
|
d->device = device;
|
|
|
|
d->deleteDevice = false;
|
|
|
|
- delete d->handler;
|
|
|
|
- d->handler = nullptr;
|
|
|
|
d->text.clear();
|
|
|
|
}
|
|
|
|
|
2023-05-05 15:43:57 +08:00
|
|
|
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
|
|
|
|
index 33f5e49..a679f25 100644
|
2023-05-05 14:54:31 +08:00
|
|
|
--- a/src/gui/image/qimagewriter.cpp
|
|
|
|
+++ b/src/gui/image/qimagewriter.cpp
|
2023-05-05 15:43:57 +08:00
|
|
|
@@ -349,9 +349,9 @@ QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format)
|
2023-05-05 14:54:31 +08:00
|
|
|
*/
|
|
|
|
QImageWriter::~QImageWriter()
|
|
|
|
{
|
|
|
|
+ delete d->handler;
|
|
|
|
if (d->deleteDevice)
|
|
|
|
delete d->device;
|
|
|
|
- delete d->handler;
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -396,13 +396,13 @@ QByteArray QImageWriter::format() const
|
|
|
|
*/
|
|
|
|
void QImageWriter::setDevice(QIODevice *device)
|
|
|
|
{
|
|
|
|
+ delete d->handler;
|
|
|
|
+ d->handler = nullptr;
|
|
|
|
if (d->device && d->deleteDevice)
|
|
|
|
delete d->device;
|
|
|
|
|
|
|
|
d->device = device;
|
|
|
|
d->deleteDevice = false;
|
|
|
|
- delete d->handler;
|
|
|
|
- d->handler = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|