diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index 0b4b2653..da5bb06d 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -94,10 +94,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl) } if (hdrLen >= 0x19A) { - quint32 size; + quint32 size, flags; if (!(seek(hdl, _gmpOffset + 0x184) && readUInt32(hdl, _imgOffsetsOffset) && readUInt32(hdl, size) && readUInt16(hdl, _imgOffsetsRecordSize) - && readUInt32(hdl, _imgOffsetsFlags) && readUInt32(hdl, _imgOffset) + && readUInt32(hdl, flags) && readUInt32(hdl, _imgOffset) && readUInt32(hdl, _imgSize))) return false; _imgOffsetsCount = size ? size / _imgOffsetsRecordSize : 0; @@ -305,7 +305,7 @@ QByteArray LBLFile::readImage(Handle &hdl, quint32 id) const { quint32 offset, nextOffset, size; - if (!_imgOffsetsCount || id >= _imgOffsetsCount) + if (id >= _imgOffsetsCount) return QByteArray(); if (!(seek(hdl, _imgOffsetsOffset + id * _imgOffsetsRecordSize) diff --git a/src/map/IMG/lblfile.h b/src/map/IMG/lblfile.h index 0831efae..222a2772 100644 --- a/src/map/IMG/lblfile.h +++ b/src/map/IMG/lblfile.h @@ -1,4 +1,4 @@ -#ifndef LBLFILE_H +#ifndef LBLFILE_H #define LBLFILE_H #include "common/textcodec.h" @@ -13,15 +13,16 @@ class LBLFile : public SubFile public: LBLFile(IMG *img) : SubFile(img), _huffmanText(0), _table(0), _offset(0), _size(0), - _poiOffset(0), _poiSize(0), _poiMultiplier(0), _multiplier(0), - _encoding(0) {} + _poiOffset(0), _poiSize(0), _imgOffsetsCount(0), _imgOffsetIdSize(0), + _poiMultiplier(0), _multiplier(0), _encoding(0) {} LBLFile(const QString *path) : SubFile(path), _huffmanText(0), _table(0), _offset(0), _size(0), - _poiOffset(0), _poiSize(0), _poiMultiplier(0), _multiplier(0), - _encoding(0) {} + _poiOffset(0), _poiSize(0), _imgOffsetsCount(0), _imgOffsetIdSize(0), + _poiMultiplier(0), _multiplier(0), _encoding(0) {} LBLFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset), _huffmanText(0), _table(0), _offset(0), _size(0), _poiOffset(0), - _poiSize(0), _poiMultiplier(0), _multiplier(0), _encoding(0) {} + _poiSize(0), _imgOffsetsCount(0), _imgOffsetIdSize(0), _poiMultiplier(0), + _multiplier(0), _encoding(0) {} ~LBLFile(); bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl); @@ -49,7 +50,6 @@ private: quint32 _imgOffsetsOffset; quint32 _imgOffsetsCount; quint32 _imgOffsetsRecordSize; - quint32 _imgOffsetsFlags; quint32 _imgOffset; quint32 _imgSize; quint8 _imgOffsetIdSize; diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index 37ad7053..08f48d94 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -58,7 +58,7 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType, } if (segmentType == Polygon && poly->type == 0x10613 - && lbl && rs >= lbl->imageIdSize() + 16U) { + && lbl && lbl->imageIdSize() && rs >= lbl->imageIdSize() + 16U) { quint32 id; quint32 top, right, bottom, left;