Related to the following bug : https://sourceforge.net/tracker/?func=detail&aid=3390961&group_id=250473&atid=1126457
It happen that the number of record declared and expected by mtkbabel in the header is greater than the number of record successfully decoded (this is the case for the GPSport 245 when non written data is found).
When this occurs mtkbabel tries to decode as much as expected and goes beyond the current sector (and giving checksum errors).
The following patch detect if there's enough space to accomodate a record in the sector based on the actual data log size, if not it terminate the sector decoding even if the header say there's more records.
Even for other device, I think this is a good sanity check to be performed.
Patch don't decode after reaching the end of a sector