[MPlayer-dev-eng] [PATCH] broken MAX_STREAMS comparisons in demux_real.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Apr 14 16:02:54 CEST 2006


Hi,
since for some unknown reasons (may I call it a brainfart?) the
stream_id variables in demux_real are signed, comparisons like
if (stream_id < MAX_STREAMS)
are not very useful.
Attached patch is one way to fix it, properly using signed/unsigned in
the variable declarations might make more sense though...

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.94
diff -u -r1.94 demux_real.c
--- libmpdemux/demux_real.c	27 Mar 2006 17:25:41 -0000	1.94
+++ libmpdemux/demux_real.c	14 Apr 2006 14:00:38 -0000
@@ -162,7 +162,7 @@
     if ( mp_msg_test(MSGT_DEMUX,MSGL_V) )
 	return;
     
-    if (stream_id >= MAX_STREAMS)
+    if ((unsigned)stream_id >= MAX_STREAMS)
 	return;
 
     index = priv->index_table[stream_id];
@@ -1040,7 +1040,7 @@
 	return 1;
     }
 
-if(stream_id<MAX_STREAMS){
+if((unsigned)stream_id<MAX_STREAMS){
 
     if(demuxer->audio->id==-1 && demuxer->a_streams[stream_id]){
 	sh_audio_t *sh = demuxer->a_streams[stream_id];
@@ -1635,14 +1635,14 @@
 		    priv->is_multirate = 1;
 		    stream_skip(demuxer->stream, 4); // Length of codec data (repeated)
 		    stream_cnt = stream_read_dword(demuxer->stream); // Get number of audio or video streams
-		    if (stream_cnt >= MAX_STREAMS) {
+		    if ((unsigned)stream_cnt >= MAX_STREAMS) {
 		        mp_msg(MSGT_DEMUX,MSGL_ERR,"Too many streams in %s. Big troubles ahead.\n", mimet);
 		        goto skip_this_chunk;
 		    }
 		    for (i = 0; i < stream_cnt; i++)
 		        stream_list[i] = stream_read_word(demuxer->stream);
 		    for (i = 0; i < stream_cnt; i++)
-		        if (stream_list[i] >= MAX_STREAMS) {
+		        if ((unsigned)stream_list[i] >= MAX_STREAMS) {
 		            mp_msg(MSGT_DEMUX,MSGL_ERR,"Stream id out of range: %d. Ignored.\n", stream_list[i]);
 		            stream_skip(demuxer->stream, 4); // Skip DATA offset for broken stream
 		        } else {


More information about the MPlayer-dev-eng mailing list