demux_disc: handle new_sh_stream() fail correctly

Break the cycle on fail. Old code was checking if sh is NULL after
accessing it's fields.
This commit is contained in:
shdown 2014-08-30 13:03:30 +04:00 committed by wm4
parent 593e5e4a25
commit 5bc3b7c368
1 changed files with 4 additions and 2 deletions

View File

@ -135,19 +135,21 @@ static void add_streams(demuxer_t *demuxer)
}
}
struct sh_stream *sh = new_sh_stream(demuxer, src->type);
if (!sh)
break;
assert(p->num_streams == n); // directly mapped
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sh);
// Copy all stream fields that might be relevant
sh->codec = talloc_strdup(sh, src->codec);
sh->format = src->format;
sh->lav_headers = src->lav_headers;
if (sh && src->video) {
if (src->video) {
double ar;
if (stream_control(demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar)
== STREAM_OK)
sh->video->aspect = ar;
}
if (sh && src->audio)
if (src->audio)
sh->audio = src->audio;
}
reselect_streams(demuxer);