changeset 13641:a22f1b86ec0f

some memory leaks fixed
author reimar
date Thu, 14 Oct 2004 15:09:35 +0000
parents a7d080bc610f
children 86f21713c356
files libmpcodecs/ad_libvorbis.c libmpcodecs/vf_palette.c libmpdemux/demux_ogg.c libvo/font_load.c
diffstat 4 files changed, 36 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_libvorbis.c	Thu Oct 14 13:03:03 2004 +0000
+++ b/libmpcodecs/ad_libvorbis.c	Thu Oct 14 15:09:35 2004 +0000
@@ -164,6 +164,7 @@
 static void uninit(sh_audio_t *sh)
 {
   struct ov_struct_st *ov = sh->context;
+  vorbis_dsp_clear(&ov->vd);
   vorbis_block_clear(&ov->vb);
   vorbis_info_clear(&ov->vi);
   free(ov);
--- a/libmpcodecs/vf_palette.c	Thu Oct 14 13:03:03 2004 +0000
+++ b/libmpcodecs/vf_palette.c	Thu Oct 14 15:09:35 2004 +0000
@@ -163,9 +163,14 @@
     return vf->next->query_format(vf->next,best);
 }
 
+static void uninit(vf_instance_t *vf) {
+  free(vf->priv);
+}
+
 static int open(vf_instance_t *vf, char* args){
     unsigned int i;
     vf->config=config;
+    vf->uninit=uninit;
     vf->put_image=put_image;
     vf->query_format=query_format;
     vf->priv=malloc(sizeof(struct vf_priv_s));
--- a/libmpdemux/demux_ogg.c	Thu Oct 14 13:03:03 2004 +0000
+++ b/libmpdemux/demux_ogg.c	Thu Oct 14 15:09:35 2004 +0000
@@ -1424,8 +1424,13 @@
   subcp_close();
 #endif
 
+  ogg_sync_clear(&ogg_d->sync);
   if(ogg_d->subs)
+  {
+    for (i = 0; i < ogg_d->num_sub; i++)
+      ogg_stream_clear(&ogg_d->subs[i].stream);
     free(ogg_d->subs);
+  }
   if(ogg_d->syncpoints)
     free(ogg_d->syncpoints);
   if (ogg_d->text_ids)
--- a/libvo/font_load.c	Thu Oct 14 13:03:03 2004 +0000
+++ b/libvo/font_load.c	Thu Oct 14 15:09:35 2004 +0000
@@ -56,10 +56,10 @@
 int version=0;
 int first=1;
 
-desc=malloc(sizeof(font_desc_t));if(!desc) return NULL;
+desc=malloc(sizeof(font_desc_t));if(!desc) goto fail_out;
 memset(desc,0,sizeof(font_desc_t));
 
-f=fopen(fname,"rt");if(!f){ printf("font: can't open file: %s\n",fname); return NULL;}
+f=fopen(fname,"rt");if(!f){ printf("font: can't open file: %s\n",fname); goto fail_out;}
 
 i = strlen (fname) - 9;
 if ((dn = malloc(i+1))){
@@ -98,10 +98,7 @@
   if (first) {
     if (!sor[0] || sor[1] == 1 || (sor[0] == 'M' && sor[1] == 'Z') || (sor[0] == 0x1f && sor[1] == 0x8b) || (sor[0] == 1 && sor[1] == 0x66)) {
       printf("%s doesn't look like a font description, ignoring\n", fname);
-      fclose(f);
-      free(desc);
-      free(dn);
-      return NULL;
+      goto fail_out;
     }
     first = 0;
   }
@@ -141,7 +138,7 @@
         if(verbose) printf("font: Reading section: %s\n",section);
         if(strcmp(section,"[files]")==0){
             ++fontdb;
-            if(fontdb>=16){ printf("font: Too many bitmaps defined!\n");return NULL;}
+            if(fontdb>=16){ printf("font: Too many bitmaps defined!\n");goto fail_out;}
         }
         continue;
       }
@@ -160,20 +157,20 @@
       char *default_dir=MPLAYER_DATADIR "/font";
       if(pdb==2 && strcmp(p[0],"alpha")==0){
     	  char *cp;
-	  if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) return NULL;
+	  if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out;
 
 	  snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s/%s",
 		desc->fpath,p[1]);
           if(!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){
 		free(cp);
 		if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2))) 
-		   return NULL;
+		   goto fail_out;
 		snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
 			 default_dir,p[1]);
 		if (!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){
 		   printf("Can't load font bitmap: %s\n",p[1]);
 		   free(cp);
-		   return NULL;
+		   goto fail_out;
 		}
           }
 	  free(cp);
@@ -181,20 +178,20 @@
       }
       if(pdb==2 && strcmp(p[0],"bitmap")==0){
     	  char *cp;
-	  if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) return NULL;
+	  if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out;
 
 	  snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s/%s",
 		desc->fpath,p[1]);
           if(!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){
 		free(cp);
 		if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2))) 
-		   return NULL;
+		   goto fail_out;
 		snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
 			 default_dir,p[1]);
 		if (!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){
 		   printf("Can't load font bitmap: %s\n",p[1]);
 		   free(cp);
-		   return NULL;
+		   goto fail_out;
 		}
           }
 	  free(cp);
@@ -245,17 +242,15 @@
       }
   }
   printf("Syntax error in font desc: %s\n",sor);
-  free(desc);
-  fclose(f);
-  return NULL;
+  goto fail_out;
 
 }
 fclose(f);
+f = NULL;
 
  if (first == 1) {
    printf("%s is empty or a directory, ignoring\n", fname);
-   free(desc);
-   return NULL;
+   goto fail_out;
  }
 
 //printf("font: pos of U = %d\n",desc->start[218]);
@@ -263,7 +258,7 @@
 for(i=0;i<=fontdb;i++){
     if(!desc->pic_a[i] || !desc->pic_b[i]){
         printf("font: Missing bitmap(s) for sub-font #%d\n",i);
-        return NULL;
+        goto fail_out;
     }
     //if(factor!=1.0f)
     {
@@ -316,6 +311,17 @@
 printf("Font %s loaded successfully! (%d chars)\n",fname,chardb);
 
 return desc;
+
+fail_out:
+  if (f)
+    fclose(f);
+  if (desc->fpath)
+    free(desc->fpath);
+  if (desc->name)
+    free(desc->name);
+  if (desc)
+    free(desc);
+  return NULL;
 }
 
 #if 0