summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-07-19 17:53:25 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-21 16:30:41 +0200
commit16c17f5965d8913e64698c577c26fcec9402e17a (patch)
tree53d11b86c6f3afb83109cc898a092076744be954 /src
parent0ba6c8a2eca9b1611e1ced85dcae1248b24f1e45 (diff)
Fixed memory leak in the TIF handler.
Change-Id: Iaa3093b172ddbac6597169ee4217a7f6c7867e60 Reviewed-on: http://codereview.qt.nokia.com/1952 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qtiffhandler.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/image/qtiffhandler.cpp b/src/gui/image/qtiffhandler.cpp
index c753b83294..4dc9775d46 100644
--- a/src/gui/image/qtiffhandler.cpp
+++ b/src/gui/image/qtiffhandler.cpp
@@ -236,14 +236,14 @@ bool QTiffHandler::read(QImage *image)
}
} else {
// create the color table
- uint16 *redTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16)));
- uint16 *greenTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16)));
- uint16 *blueTable = static_cast<uint16 *>(qMalloc(tableSize * sizeof(uint16)));
- if (!redTable || !greenTable || !blueTable) {
+ uint16 *redTable = 0;
+ uint16 *greenTable = 0;
+ uint16 *blueTable = 0;
+ if (!TIFFGetField(tiff, TIFFTAG_COLORMAP, &redTable, &greenTable, &blueTable)) {
TIFFClose(tiff);
return false;
}
- if (!TIFFGetField(tiff, TIFFTAG_COLORMAP, &redTable, &greenTable, &blueTable)) {
+ if (!redTable || !greenTable || !blueTable) {
TIFFClose(tiff);
return false;
}
@@ -500,6 +500,9 @@ bool QTiffHandler::write(const QImage &image)
uint16 *greenTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16)));
uint16 *blueTable = static_cast<uint16 *>(qMalloc(256 * sizeof(uint16)));
if (!redTable || !greenTable || !blueTable) {
+ qFree(redTable);
+ qFree(greenTable);
+ qFree(blueTable);
TIFFClose(tiff);
return false;
}