changeset 23548:ac72a4e46c45

Make sure we do not access demuxer->s_streams out of bounds when invalid -sid is given
author reimar
date Sun, 17 Jun 2007 08:26:07 +0000
parents 7acb7ac64104
children 439dafcb16a5
files command.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/command.c	Sat Jun 16 19:47:36 2007 +0000
+++ b/command.c	Sun Jun 17 08:26:07 2007 +0000
@@ -1257,14 +1257,16 @@
 	    if (mpctx->stream->type != STREAMTYPE_DVD
 		&& mpctx->stream->type != STREAMTYPE_DVDNAV) {
 		int i = 0;
+		d_sub->sh = NULL;
 		for (d_sub->id = 0; d_sub->id < MAX_S_STREAMS; d_sub->id++) {
 		    if (mpctx->demuxer->s_streams[d_sub->id]) {
-			if (i == dvdsub_id)
+			if (i == dvdsub_id) {
+			    d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
 			    break;
+			}
 			i++;
 		    }
 		}
-		d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
 	    }
 	    if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
 		d_sub->id = demux_mkv_change_subs(mpctx->demuxer, dvdsub_id);