mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2026-11-03 00:18:47 -05:00
Fix memory leak of SGI row tables on repeated read()/write()
This commit is contained in:
@@ -317,6 +317,8 @@ bool SGIImagePrivate::readImage(QImage &img)
|
|||||||
// start table holds file offsets; raster data follows header + both tables
|
// start table holds file offsets; raster data follows header + both tables
|
||||||
const quint32 dataOff = 512 + _numrows * 2 * sizeof(quint32);
|
const quint32 dataOff = 512 + _numrows * 2 * sizeof(quint32);
|
||||||
uint l;
|
uint l;
|
||||||
|
|
||||||
|
delete[] _starttab;
|
||||||
_starttab = new (std::nothrow) quint32[_numrows];
|
_starttab = new (std::nothrow) quint32[_numrows];
|
||||||
if (_starttab == nullptr) {
|
if (_starttab == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
@@ -335,6 +337,7 @@ bool SGIImagePrivate::readImage(QImage &img)
|
|||||||
_starttab[l] = 0;
|
_starttab[l] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] _lengthtab;
|
||||||
_lengthtab = new (std::nothrow) quint32[_numrows];
|
_lengthtab = new (std::nothrow) quint32[_numrows];
|
||||||
if (_lengthtab == nullptr) {
|
if (_lengthtab == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
@@ -802,6 +805,7 @@ bool SGIImagePrivate::writeImage(const QImage &image)
|
|||||||
_pixmax = 0;
|
_pixmax = 0;
|
||||||
_colormap = NORMAL;
|
_colormap = NORMAL;
|
||||||
_numrows = _ysize * _zsize;
|
_numrows = _ysize * _zsize;
|
||||||
|
delete[] _starttab;
|
||||||
_starttab = new (std::nothrow) quint32[_numrows];
|
_starttab = new (std::nothrow) quint32[_numrows];
|
||||||
if (_starttab == nullptr) {
|
if (_starttab == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user