mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Fixed error handling
This commit is contained in:
parent
a4648020d9
commit
8196b96f65
@ -26,4 +26,16 @@ inline quint8 bs(const quint8 val)
|
||||
return (val + 7) >> 3;
|
||||
}
|
||||
|
||||
inline quint8 byteSize(quint32 val)
|
||||
{
|
||||
quint8 ret = 0;
|
||||
|
||||
do {
|
||||
ret++;
|
||||
val = val >> 8;
|
||||
} while (val != 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // GARMIN_H
|
||||
|
@ -55,18 +55,6 @@ static QString capitalized(const QString &str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static quint8 byteSize(quint32 val)
|
||||
{
|
||||
quint8 ret = 0;
|
||||
|
||||
do {
|
||||
ret++;
|
||||
val = val >> 8;
|
||||
} while (val != 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
LBLFile::~LBLFile()
|
||||
{
|
||||
|
@ -381,7 +381,7 @@ bool NETFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
|
||||
&& readUInt32(hdl, _size) && readByte(hdl, &_shift)))
|
||||
return false;
|
||||
|
||||
if (hdrLen >= 0x47) {
|
||||
if (hdrLen >= 0x4C) {
|
||||
quint32 info;
|
||||
if (!(seek(hdl, _gmpOffset + 0x37) && readUInt32(hdl, info)))
|
||||
return false;
|
||||
@ -389,7 +389,7 @@ bool NETFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
|
||||
&& readUInt32(hdl, _linksSize) && readByte(hdl, &_linksShift)))
|
||||
return false;
|
||||
|
||||
quint8 tableId = ((info >> 2) & 0xF);
|
||||
quint8 tableId = ((info >> 2) & 0x0F);
|
||||
if (_linksSize && (!rgn->huffmanTable() || rgn->huffmanTable()->id()
|
||||
!= tableId)) {
|
||||
_huffmanTable = new HuffmanTable(tableId);
|
||||
|
@ -88,9 +88,8 @@ bool NODFile::load(Handle &hdl)
|
||||
|
||||
if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen)))
|
||||
return false;
|
||||
if (hdrLen < 0x7b)
|
||||
return true;
|
||||
|
||||
if (hdrLen >= 0x7F) {
|
||||
if (!(seek(hdl, _gmpOffset + 0x1d) && readUInt32(hdl, _flags)
|
||||
&& readByte(hdl, &_blockShift) && readByte(hdl, &_nodeShift)))
|
||||
return false;
|
||||
@ -101,17 +100,13 @@ bool NODFile::load(Handle &hdl)
|
||||
&& readUInt16(hdl, _indexRecordSize) && readUInt32(hdl, _indexFlags)))
|
||||
return false;
|
||||
|
||||
if (!_indexRecordSize)
|
||||
if (!_indexRecordSize || _indexSize < _indexRecordSize)
|
||||
return false;
|
||||
quint32 indexCount = _indexSize / _indexRecordSize;
|
||||
if (indexCount <= 0x100)
|
||||
_indexIdSize = 1;
|
||||
else if (indexCount <= 0x1000)
|
||||
_indexIdSize = 2;
|
||||
else if (indexCount <= 0x1000000)
|
||||
_indexIdSize = 3;
|
||||
_indexIdSize = byteSize(indexCount - 1);
|
||||
}
|
||||
|
||||
return (_indexIdSize > 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NODFile::readBlock(Handle &hdl, quint32 blockOffset,
|
||||
|
Loading…
Reference in New Issue
Block a user