Fixed some potential and actual segfaults: a lot of readers did not check if the packetizer for a track had been initialized.

This commit is contained in:
Moritz Bunkus 2005-11-12 17:41:01 +00:00
parent 473b30339e
commit 440d7d0fbe
9 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2005-11-12 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: Fixed a couple of potential (and actual)
segmentation faults by accessing invalid memory addresses. Initial
patch for the VobSub reader by Issa on Doom9's forum.
2005-11-04 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge, mmg: new feature: The names of attached files can be

View File

@ -469,7 +469,7 @@ avi_reader_c::read(generic_packetizer_c *ptzr,
return read_video();
foreach(demuxer, ademuxers)
if (PTZR(demuxer->ptzr) == ptzr)
if ((-1 != demuxer->ptzr) && (PTZR(demuxer->ptzr) == ptzr))
return read_audio(*demuxer);
return FILE_STATUS_DONE;

View File

@ -173,7 +173,7 @@ kax_reader_c::packets_available() {
int i;
for (i = 0; i < tracks.size(); i++)
if (tracks[i]->ok && (!PTZR(tracks[i]->ptzr)->packet_available()))
if ((-1 != tracks[i]->ptzr) && !PTZR(tracks[i]->ptzr)->packet_available())
return 0;
if (tracks.size() == 0)

View File

@ -613,7 +613,8 @@ ogm_reader_c::packet_available() {
return 0;
for (i = 0; i < sdemuxers.size(); i++)
if (!PTZR(sdemuxers[i]->ptzr)->packet_available())
if ((-1 != sdemuxers[i]->ptzr) &&
!PTZR(sdemuxers[i]->ptzr)->packet_available())
return 0;
return 1;
@ -804,7 +805,7 @@ ogm_reader_c::process_page(ogg_page *og) {
duration = 0;
dmx = find_demuxer(ogg_page_serialno(og));
if (dmx == NULL)
if ((NULL == dmx) || (-1 == dmx->ptzr))
return;
debug_enter("ogm_reader_c::process_page");

View File

@ -1071,7 +1071,7 @@ qtmp4_reader_c::read(generic_packetizer_c *ptzr,
for (i = 0; i < demuxers.size(); i++) {
qtmp4_demuxer_ptr &dmx = demuxers[i];
if (PTZR(dmx->ptzr) != ptzr)
if ((-1 == dmx->ptzr) || (PTZR(dmx->ptzr) != ptzr))
continue;
if (dmx->sample_size != 0) {

View File

@ -501,7 +501,7 @@ real_reader_c::read(generic_packetizer_c *,
timecode = (int64_t)frame->timecode * 1000000ll;
dmx = find_demuxer(frame->id);
if (dmx.get() == NULL) {
if ((dmx.get() == NULL) || (-1 == dmx->ptzr)) {
rmff_release_frame(frame);
return FILE_STATUS_MOREDATA;
}
@ -568,7 +568,7 @@ real_reader_c::deliver_audio_frames(real_demuxer_cptr dmx,
uint32_t i;
rv_segment_cptr segment;
if (dmx->segments.empty())
if (dmx->segments.empty() || (-1 == dmx->ptzr))
return;
for (i = 0; i < dmx->segments.size(); i++) {

View File

@ -291,7 +291,7 @@ usf_reader_c::read(generic_packetizer_c *ptzr,
track = NULL;
for (i = 0; m_tracks.size() > i; ++i)
if (PTZR(m_tracks[i].m_ptzr) == ptzr) {
if ((-1 != m_tracks[i].m_ptzr) && (PTZR(m_tracks[i].m_ptzr) == ptzr)) {
track = &m_tracks[i];
break;
}

View File

@ -86,7 +86,8 @@ vobbtn_reader_c::~vobbtn_reader_c() {
void
vobbtn_reader_c::create_packetizer(int64_t tid) {
ti.id = tid;
add_packetizer(new vobbtn_packetizer_c(this, width, height, ti));
if (demuxing_requested('s', tid))
add_packetizer(new vobbtn_packetizer_c(this, width, height, ti));
}
file_status_e

View File

@ -561,7 +561,7 @@ vobsub_reader_c::read(generic_packetizer_c *ptzr,
track = NULL;
for (i = 0; i < tracks.size(); i++)
if (PTZR(tracks[i]->ptzr) == ptzr) {
if ((-1 != tracks[i]->ptzr) && (PTZR(tracks[i]->ptzr) == ptzr)) {
track = tracks[i];
break;
}