1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added propper error handling

This commit is contained in:
Martin Tůma 2021-01-25 23:01:36 +01:00
parent a9c2b30bd6
commit 02c3682758
3 changed files with 11 additions and 11 deletions

View File

@ -94,10 +94,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
} }
if (hdrLen >= 0x19A) { if (hdrLen >= 0x19A) {
quint32 size; quint32 size, flags;
if (!(seek(hdl, _gmpOffset + 0x184) && readUInt32(hdl, _imgOffsetsOffset) if (!(seek(hdl, _gmpOffset + 0x184) && readUInt32(hdl, _imgOffsetsOffset)
&& readUInt32(hdl, size) && readUInt16(hdl, _imgOffsetsRecordSize) && readUInt32(hdl, size) && readUInt16(hdl, _imgOffsetsRecordSize)
&& readUInt32(hdl, _imgOffsetsFlags) && readUInt32(hdl, _imgOffset) && readUInt32(hdl, flags) && readUInt32(hdl, _imgOffset)
&& readUInt32(hdl, _imgSize))) && readUInt32(hdl, _imgSize)))
return false; return false;
_imgOffsetsCount = size ? size / _imgOffsetsRecordSize : 0; _imgOffsetsCount = size ? size / _imgOffsetsRecordSize : 0;
@ -305,7 +305,7 @@ QByteArray LBLFile::readImage(Handle &hdl, quint32 id) const
{ {
quint32 offset, nextOffset, size; quint32 offset, nextOffset, size;
if (!_imgOffsetsCount || id >= _imgOffsetsCount) if (id >= _imgOffsetsCount)
return QByteArray(); return QByteArray();
if (!(seek(hdl, _imgOffsetsOffset + id * _imgOffsetsRecordSize) if (!(seek(hdl, _imgOffsetsOffset + id * _imgOffsetsRecordSize)

View File

@ -1,4 +1,4 @@
#ifndef LBLFILE_H #ifndef LBLFILE_H
#define LBLFILE_H #define LBLFILE_H
#include "common/textcodec.h" #include "common/textcodec.h"
@ -13,15 +13,16 @@ class LBLFile : public SubFile
public: public:
LBLFile(IMG *img) LBLFile(IMG *img)
: SubFile(img), _huffmanText(0), _table(0), _offset(0), _size(0), : SubFile(img), _huffmanText(0), _table(0), _offset(0), _size(0),
_poiOffset(0), _poiSize(0), _poiMultiplier(0), _multiplier(0), _poiOffset(0), _poiSize(0), _imgOffsetsCount(0), _imgOffsetIdSize(0),
_encoding(0) {} _poiMultiplier(0), _multiplier(0), _encoding(0) {}
LBLFile(const QString *path) LBLFile(const QString *path)
: SubFile(path), _huffmanText(0), _table(0), _offset(0), _size(0), : SubFile(path), _huffmanText(0), _table(0), _offset(0), _size(0),
_poiOffset(0), _poiSize(0), _poiMultiplier(0), _multiplier(0), _poiOffset(0), _poiSize(0), _imgOffsetsCount(0), _imgOffsetIdSize(0),
_encoding(0) {} _poiMultiplier(0), _multiplier(0), _encoding(0) {}
LBLFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset), LBLFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset),
_huffmanText(0), _table(0), _offset(0), _size(0), _poiOffset(0), _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(); ~LBLFile();
bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl); bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl);
@ -49,7 +50,6 @@ private:
quint32 _imgOffsetsOffset; quint32 _imgOffsetsOffset;
quint32 _imgOffsetsCount; quint32 _imgOffsetsCount;
quint32 _imgOffsetsRecordSize; quint32 _imgOffsetsRecordSize;
quint32 _imgOffsetsFlags;
quint32 _imgOffset; quint32 _imgOffset;
quint32 _imgSize; quint32 _imgSize;
quint8 _imgOffsetIdSize; quint8 _imgOffsetIdSize;

View File

@ -58,7 +58,7 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
} }
if (segmentType == Polygon && poly->type == 0x10613 if (segmentType == Polygon && poly->type == 0x10613
&& lbl && rs >= lbl->imageIdSize() + 16U) { && lbl && lbl->imageIdSize() && rs >= lbl->imageIdSize() + 16U) {
quint32 id; quint32 id;
quint32 top, right, bottom, left; quint32 top, right, bottom, left;