[MPlayer-cvslog] CVS: main/libmpdemux demuxer.c, 1.181, 1.182 demux_ogg.c, 1.65, 1.66

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sun Feb 6 11:30:13 CET 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv23693/libmpdemux

Modified Files:
	demuxer.c demux_ogg.c 
Log Message:
Memleak fixes. Based on patch by Timothy Lee (timothy lee at siriushk com).


Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -r1.181 -r1.182
--- demuxer.c	15 Jan 2005 16:11:45 -0000	1.181
+++ demuxer.c	6 Feb 2005 10:30:10 -0000	1.182
@@ -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;
     }

Index: demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- demux_ogg.c	22 Jan 2005 14:28:23 -0000	1.65
+++ demux_ogg.c	6 Feb 2005 10:30:10 -0000	1.66
@@ -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;
 }
 
 




More information about the MPlayer-cvslog mailing list