Skip to content

Commit

Permalink
On GlobalHeap instantiation, we should stop reading file data just af…
Browse files Browse the repository at this point in the history
…ter we met a HeapObject.id equals to 0. Otherwise, we could be at the end of the file and a EOFException will be raised. Addresses the github issue Unidata#532.
  • Loading branch information
Mikhail Aoun authored and lesserwhirls committed Oct 23, 2020
1 parent a2975e0 commit 05cedba
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,8 @@ class GlobalHeap {
long startPos = raf.getFilePointer();
GlobalHeap.HeapObject o = new GlobalHeap.HeapObject();
o.id = raf.readShort();
if (o.id == 0)
break; // ?? look
o.refCount = raf.readShort();
raf.skipBytes(4);
o.dataSize = header.readLength();
Expand All @@ -2634,8 +2636,6 @@ class GlobalHeap {
int dsize = ((int) o.dataSize) + padding((int) o.dataSize, 8);
countBytes += dsize + 16;

if (o.id == 0)
break; // ?? look
if (o.dataSize < 0)
break; // ran off the end, must be done
if (countBytes < 0)
Expand Down

0 comments on commit 05cedba

Please sign in to comment.