Skip to content

Commit 8c7d336

Browse files
StefanBruensufleisch
authored andcommitted
Fix reading of last page in ogg stream
When trying to read a packet from the last page the readPages() method would return false for all packets on the last page. Move the lastPage check just before trying to create the next page, and after the packetIndex check of the last fetched page.
1 parent b4a4b42 commit 8c7d336

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

taglib/ogg/oggfile.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ bool Ogg::File::readPages(unsigned int i)
191191
const Page *page = d->pages.back();
192192
packetIndex = nextPacketIndex(page);
193193
offset = page->fileOffset() + page->size();
194-
}
195-
196-
// Enough pages have been fetched.
197194

198-
if(packetIndex > i)
199-
return true;
195+
// Enough pages have been fetched.
196+
if(packetIndex > i) {
197+
return true;
198+
}
199+
else if(page->header()->lastPageOfStream()) {
200+
return false;
201+
}
202+
}
200203

201204
// Read the next page and add it to the page list.
202205

@@ -208,9 +211,6 @@ bool Ogg::File::readPages(unsigned int i)
208211

209212
nextPage->setFirstPacketIndex(packetIndex);
210213
d->pages.append(nextPage);
211-
212-
if(nextPage->header()->lastPageOfStream())
213-
return false;
214214
}
215215
}
216216

0 commit comments

Comments
 (0)