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>
This commit is contained in:
Kim Motoyoshi Kalland 2011-07-19 17:53:25 +02:00 committed by Qt by Nokia
parent 0ba6c8a2ec
commit 16c17f5965

View File

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