summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2015-07-04 13:18:27 +0800
committerjian liang <jianliang79@gmail.com>2015-07-06 14:53:35 +0000
commit6f244dc84d87f382f584187b8758f6fa918c211c (patch)
tree05ab3b3fd8e0c2e79559dbb2b92f3085a04c689e /src/gui
parent8a928783b942ac5cc53e16eda07e418a6ac7d61d (diff)
Fix memory leak in QJpegHandlerPrivate
Since the introduction of jpeg auto transform, it is possible to read jpeg header after its state was changed from ReadHeaer to Ready which will lead to creating some resources again without releasing them. For example, if you call QImageReader::setAutoTransform(true) and then call QImageReader::read(), QJpegHandlerPrivate::readJpegHeader() will be called twice and it will allocate resource again without releasing the old one. This patch add a new state ReadingEnd to prevent the header from being read twice. Change-Id: If2497f6e3668958c0c792a66e1b77eb2773584a2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qjpeghandler.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index c0fda647aa..e29f9783a6 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -710,6 +710,7 @@ public:
enum State {
Ready,
ReadHeader,
+ ReadingEnd,
Error
};
@@ -958,7 +959,7 @@ bool QJpegHandlerPrivate::read(QImage *image)
for (int i = 0; i < readTexts.size()-1; i+=2)
image->setText(readTexts.at(i), readTexts.at(i+1));
- state = Ready;
+ state = ReadingEnd;
return true;
}
@@ -1006,7 +1007,7 @@ bool QJpegHandler::canRead() const
if(d->state == QJpegHandlerPrivate::Ready && !canRead(device()))
return false;
- if (d->state != QJpegHandlerPrivate::Error) {
+ if (d->state != QJpegHandlerPrivate::Error && d->state != QJpegHandlerPrivate::ReadingEnd) {
setFormat("jpeg");
return true;
}