1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 23:00:41 +00:00

Memleak fixes. Based on patch by Timothy Lee (timothy lee at siriushk com).

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14667 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-02-06 10:30:10 +00:00
parent 7a9b1289a2
commit 02f5ebf1d5
2 changed files with 16 additions and 11 deletions

View File

@ -731,6 +731,8 @@ char *demux_ogg_sub_lang(demuxer_t *demuxer, int index) {
return (index < 0) ? NULL : (index >= ogg_d->n_text) ? NULL : ogg_d->text_langs[index]; return (index < 0) ? NULL : (index >= ogg_d->n_text) ? NULL : ogg_d->text_langs[index];
} }
void demux_close_ogg(demuxer_t* demuxer);
/// Open an ogg physical stream /// Open an ogg physical stream
int demux_ogg_open(demuxer_t* demuxer) { int demux_ogg_open(demuxer_t* demuxer) {
ogg_demuxer_t* ogg_d; ogg_demuxer_t* ogg_d;
@ -764,8 +766,7 @@ int demux_ogg_open(demuxer_t* demuxer) {
/// Error /// Error
if(np < 0) { if(np < 0) {
mp_msg(MSGT_DEMUX,MSGL_DBG2,"Ogg demuxer : Bad page sync\n"); mp_msg(MSGT_DEMUX,MSGL_DBG2,"Ogg demuxer : Bad page sync\n");
free(ogg_d); goto err_out;
return 0;
} }
/// Need some more data /// Need some more data
if(np == 0) { if(np == 0) {
@ -773,8 +774,7 @@ int demux_ogg_open(demuxer_t* demuxer) {
buf = ogg_sync_buffer(sync,BLOCK_SIZE); buf = ogg_sync_buffer(sync,BLOCK_SIZE);
len = stream_read(s,buf,BLOCK_SIZE); len = stream_read(s,buf,BLOCK_SIZE);
if(len == 0 && s->eof) { if(len == 0 && s->eof) {
free(ogg_d); goto err_out;
return 0;
} }
ogg_sync_wrote(sync,len); ogg_sync_wrote(sync,len);
continue; continue;
@ -1057,8 +1057,7 @@ int demux_ogg_open(demuxer_t* demuxer) {
} }
if(!n_video && !n_audio) { if(!n_video && !n_audio) {
free(ogg_d); goto err_out;
return 0;
} }
/// Finish to setup the demuxer /// Finish to setup the demuxer
@ -1095,6 +1094,10 @@ int demux_ogg_open(demuxer_t* demuxer) {
mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",ogg_d->n_text,ogg_d->n_text>1?"s":""); mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",ogg_d->n_text,ogg_d->n_text>1?"s":"");
return 1; return 1;
err_out:
demux_close_ogg(demuxer);
return 0;
} }

View File

@ -219,13 +219,13 @@ void free_demuxer(demuxer_t *demuxer){
demux_close_rtp(demuxer); break; demux_close_rtp(demuxer); break;
#endif #endif
case DEMUXER_TYPE_SMJPEG: case DEMUXER_TYPE_SMJPEG:
demux_close_smjpeg(demuxer); return; demux_close_smjpeg(demuxer); break;
case DEMUXER_TYPE_DEMUXERS: case DEMUXER_TYPE_DEMUXERS:
demux_close_demuxers(demuxer); return; demux_close_demuxers(demuxer); break;
case DEMUXER_TYPE_AVI: case DEMUXER_TYPE_AVI:
case DEMUXER_TYPE_AVI_NI: case DEMUXER_TYPE_AVI_NI:
case DEMUXER_TYPE_AVI_NINI: case DEMUXER_TYPE_AVI_NINI:
demux_close_avi(demuxer); return; demux_close_avi(demuxer); break;
#ifdef HAVE_XMMS #ifdef HAVE_XMMS
case DEMUXER_TYPE_XMMS: case DEMUXER_TYPE_XMMS:
demux_close_xmms(demuxer); break; demux_close_xmms(demuxer); break;
@ -250,10 +250,10 @@ void free_demuxer(demuxer_t *demuxer){
#endif #endif
} }
// free streams: // free streams:
for(i=0;i<256;i++){ for(i = 0; i < MAX_A_STREAMS; i++)
if(demuxer->a_streams[i]) free_sh_audio(demuxer->a_streams[i]); if(demuxer->a_streams[i]) free_sh_audio(demuxer->a_streams[i]);
for(i = 0; i < MAX_V_STREAMS; i++)
if(demuxer->v_streams[i]) free_sh_video(demuxer->v_streams[i]); if(demuxer->v_streams[i]) free_sh_video(demuxer->v_streams[i]);
}
//if(sh_audio) free_sh_audio(sh_audio); //if(sh_audio) free_sh_audio(sh_audio);
//if(sh_video) free_sh_video(sh_video); //if(sh_video) free_sh_video(sh_video);
// free demuxers: // free demuxers:
@ -1050,6 +1050,8 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug); mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
else else
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream); mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream);
}
if (demuxer && file_format != DEMUXER_TYPE_MPEG_PS) {
free_demuxer(demuxer); free_demuxer(demuxer);
demuxer = NULL; demuxer = NULL;
} }