Commit 822b0af6 authored by conrad's avatar conrad

Mozilla #506878: check oggz_stream_get_content() return values

parent 0997b434
......@@ -256,6 +256,12 @@ oggz_read_update_gp(void *elem) {
if (p->calced_granulepos == -1 && p->stream->last_granulepos != -1) {
int content = oggz_stream_get_content(p->oggz, p->serialno);
/* Cancel the iteration (backwards through buffered packets)
* if we don't know the codec */
if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN)
return DLIST_ITER_CANCEL;
p->calced_granulepos =
oggz_auto_calculate_gp_backwards(content, p->stream->last_granulepos,
p->stream, &(p->packet), p->stream->last_packet);
......@@ -384,32 +390,28 @@ oggz_read_sync (OGGZ * oggz)
granulepos = op->granulepos;
content = oggz_stream_get_content(oggz, serialno);
/*
* if we have no metrics for this stream yet, then generate them
*/
if
(
(!stream->metric || (content == OGGZ_CONTENT_SKELETON))
&&
(oggz->flags & OGGZ_AUTO)
)
{
oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
}
if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) {
reader->current_granulepos = granulepos;
} else {
/* if we have no metrics for this stream yet, then generate them */
if ((!stream->metric || content == OGGZ_CONTENT_SKELETON) &&
(oggz->flags & OGGZ_AUTO)) {
oggz_auto_read_bos_packet (oggz, op, serialno, NULL);
}
/* attempt to determine granulepos for this packet */
if (oggz->flags & OGGZ_AUTO) {
reader->current_granulepos =
oggz_auto_calculate_granulepos (content, granulepos, stream, op);
/* make sure that we accept any "real" gaps in the granulepos
*/
if (granulepos != -1 && reader->current_granulepos < granulepos) {
/* attempt to determine granulepos for this packet */
if (oggz->flags & OGGZ_AUTO) {
reader->current_granulepos =
oggz_auto_calculate_granulepos (content, granulepos, stream, op);
/* make sure that we accept any "real" gaps in the granulepos */
if (granulepos != -1 && reader->current_granulepos < granulepos) {
reader->current_granulepos = granulepos;
}
} else {
reader->current_granulepos = granulepos;
}
} else {
reader->current_granulepos = granulepos;
}
}
stream->last_granulepos = reader->current_granulepos;
/* set unit on last packet of page */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment