Mercurial > mplayer.hg
changeset 14666:91bbfcb66883
Memleak fixes. Based on patch by Timothy Lee (timothy lee at siriushk com).
author | reimar |
---|---|
date | Sun, 06 Feb 2005 10:30:10 +0000 |
parents | e07e06c06932 |
children | 7c1de83ce978 |
files | libmpdemux/demux_ogg.c libmpdemux/demuxer.c |
diffstat | 2 files changed, 16 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_ogg.c Sun Feb 06 10:26:48 2005 +0000 +++ b/libmpdemux/demux_ogg.c Sun Feb 06 10:30:10 2005 +0000 @@ -731,6 +731,8 @@ 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 int demux_ogg_open(demuxer_t* demuxer) { ogg_demuxer_t* ogg_d; @@ -764,8 +766,7 @@ /// Error if(np < 0) { mp_msg(MSGT_DEMUX,MSGL_DBG2,"Ogg demuxer : Bad page sync\n"); - free(ogg_d); - return 0; + goto err_out; } /// Need some more data if(np == 0) { @@ -773,8 +774,7 @@ buf = ogg_sync_buffer(sync,BLOCK_SIZE); len = stream_read(s,buf,BLOCK_SIZE); if(len == 0 && s->eof) { - free(ogg_d); - return 0; + goto err_out; } ogg_sync_wrote(sync,len); continue; @@ -1057,8 +1057,7 @@ } if(!n_video && !n_audio) { - free(ogg_d); - return 0; + goto err_out; } /// Finish to setup the demuxer @@ -1095,6 +1094,10 @@ 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; + +err_out: + demux_close_ogg(demuxer); + return 0; }
--- a/libmpdemux/demuxer.c Sun Feb 06 10:26:48 2005 +0000 +++ b/libmpdemux/demuxer.c Sun Feb 06 10:30:10 2005 +0000 @@ -219,13 +219,13 @@ demux_close_rtp(demuxer); break; #endif case DEMUXER_TYPE_SMJPEG: - demux_close_smjpeg(demuxer); return; + demux_close_smjpeg(demuxer); break; case DEMUXER_TYPE_DEMUXERS: - demux_close_demuxers(demuxer); return; + demux_close_demuxers(demuxer); break; case DEMUXER_TYPE_AVI: case DEMUXER_TYPE_AVI_NI: case DEMUXER_TYPE_AVI_NINI: - demux_close_avi(demuxer); return; + demux_close_avi(demuxer); break; #ifdef HAVE_XMMS case DEMUXER_TYPE_XMMS: demux_close_xmms(demuxer); break; @@ -250,10 +250,10 @@ #endif } // 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]); + for(i = 0; i < MAX_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_video) free_sh_video(sh_video); // free demuxers: @@ -1050,6 +1050,8 @@ mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug); else mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream); + } + if (demuxer && file_format != DEMUXER_TYPE_MPEG_PS) { free_demuxer(demuxer); demuxer = NULL; }