check for overflow in new_sh_video and new_sh_audio

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4643 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2002-02-10 18:09:20 +00:00
parent c39eb8fb59
commit 266c02e2e4
2 changed files with 17 additions and 2 deletions

View File

@ -67,6 +67,12 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){
}
sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
if(id > MAX_A_STREAMS-1)
{
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n",
id, MAX_A_STREAMS);
return NULL;
}
if(demuxer->a_streams[id]){
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id);
} else {
@ -85,6 +91,12 @@ void free_sh_audio(sh_audio_t* sh){
}
sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
if(id > MAX_V_STREAMS-1)
{
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n",
id, MAX_V_STREAMS);
return NULL;
}
if(demuxer->v_streams[id]){
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
} else {

View File

@ -71,6 +71,9 @@ typedef struct demuxer_info_st {
char *copyright;
} demuxer_info_t;
#define MAX_A_STREAMS 256
#define MAX_V_STREAMS 256
typedef struct demuxer_st {
stream_t *stream;
int synced; // stream synced (used by mpeg)
@ -86,8 +89,8 @@ typedef struct demuxer_st {
demux_stream_t *sub; // dvd subtitle buffer/demuxer
// stream headers:
void* a_streams[256]; // audio streams (sh_audio_t)
void* v_streams[256]; // video sterams (sh_video_t)
void* a_streams[MAX_A_STREAMS]; // audio streams (sh_audio_t)
void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t)
char s_streams[32]; // dvd subtitles (flag)
void* priv; // fileformat-dependent data