Check for resetting timecodes in the middle of Ogg/OGM files. Fixes Anthill bug #166.

This commit is contained in:
Moritz Bunkus 2005-11-12 19:25:13 +00:00
parent a54cce80c3
commit affa49e62f
2 changed files with 24 additions and 1 deletions

View File

@ -1,7 +1,11 @@
2005-11-12 Moritz Bunkus <moritz@bunkus.org> 2005-11-12 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: Fixed a crash If the granulepos (the
timecodes) reset in the middle of an Ogg/OGM file. Fixes Anthill
bug #166.
* mkvmerge: bug fix: Fixed a division-by-zero error in the * mkvmerge: bug fix: Fixed a division-by-zero error in the
RealMedia demuxer. RealMedia demuxer. Fixes Anthill bug #161.
* mkvmerge: bug fix: Fixed a couple of potential (and actual) * mkvmerge: bug fix: Fixed a couple of potential (and actual)
segmentation faults by accessing invalid memory addresses. Initial segmentation faults by accessing invalid memory addresses. Initial

View File

@ -802,14 +802,26 @@ ogm_reader_c::process_page(ogg_page *og) {
ogg_packet op; ogg_packet op;
int duration_len, eos, i; int duration_len, eos, i;
long duration; long duration;
bool last_granulepos_set;
duration = 0; duration = 0;
dmx = find_demuxer(ogg_page_serialno(og)); dmx = find_demuxer(ogg_page_serialno(og));
if ((NULL == dmx) || (-1 == dmx->ptzr)) if ((NULL == dmx) || (-1 == dmx->ptzr))
return; return;
if ((-1 != ogg_page_granulepos(og)) &&
(ogg_page_granulepos(og) < dmx->last_granulepos)) {
mxwarn(FMT_TID "The timecodes for this stream have been reset in the "
"middle of the file. This is not supported. The current packet "
"will be discarded.\n", ti.fname.c_str(),
(int64_t)dmx->serialno);
return;
}
debug_enter("ogm_reader_c::process_page"); debug_enter("ogm_reader_c::process_page");
last_granulepos_set = false;
ogg_stream_pagein(&dmx->os, og); ogg_stream_pagein(&dmx->os, og);
while (ogg_stream_packetout(&dmx->os, &op) == 1) { while (ogg_stream_packetout(&dmx->os, &op) == 1) {
eos = op.e_o_s; eos = op.e_o_s;
@ -841,6 +853,8 @@ ogm_reader_c::process_page(ogg_page *og) {
return; return;
} }
last_granulepos_set = true;
continue; continue;
} }
#endif #endif
@ -878,6 +892,8 @@ ogm_reader_c::process_page(ogg_page *og) {
return; return;
} }
last_granulepos_set = true;
continue; continue;
} }
@ -933,6 +949,9 @@ ogm_reader_c::process_page(ogg_page *og) {
} }
} }
if (!last_granulepos_set)
dmx->last_granulepos = ogg_page_granulepos(og);
debug_leave("ogm_reader_c::process_page"); debug_leave("ogm_reader_c::process_page");
} }