[MPlayer-dev-eng] [Patch] font_load.c memory free function fix

Wei Jiang jiangw98 at yahoo.com
Sat Oct 23 22:45:03 CEST 2004


Tested on XBMC with mplayer.dll come from pre5 mplayer source
wei jiang


diff -u -r1.29 font_load.c
--- libvo/font_load.c	14 Oct 2004 15:09:35 -0000	1.29
+++ libvo/font_load.c	23 Oct 2004 16:53:39 -0000
@@ -315,13 +315,47 @@
 fail_out:
   if (f)
     fclose(f);
-  if (desc->fpath)
-    free(desc->fpath);
-  if (desc->name)
-    free(desc->name);
-  if (desc)
-    free(desc);
-  return NULL;
+    free_font_desc( desc );
+}
+
+void free_font_desc( font_desc_t* desc )
+{
+    int i;
+    
+    if(desc) {
+    	if (desc->fpath){
+    		free(desc->fpath);
+    		desc->fpath = NULL;
+    	}
+    	for(i=0;i<16;i++) {
+    		if(desc->pic_a[i]){
+    			if(desc->pic_a[i]->pal){
+    				free(desc->pic_a[i]->pal);
+    				desc->pic_a[i]->pal = NULL;
+    			}
+    			if(desc->pic_a[i]->bmp){
+    				free(desc->pic_a[i]->bmp);
+    				desc->pic_a[i]->bmp = NULL;
+    			}
+    			free(desc->pic_a[i]);
+    			desc->pic_a[i] = NULL;
+    		}
+    		if(desc->pic_b[i]){
+    			if(desc->pic_b[i]->pal){
+    				free(desc->pic_b[i]->pal);
+    				desc->pic_b[i]->pal = NULL;
+    			}
+    			if(desc->pic_b[i]->bmp){
+    				free(desc->pic_b[i]->bmp);
+    				desc->pic_b[i]->bmp = NULL;
+    			}
+    			free(desc->pic_b[i]);
+    			desc->pic_b[i] = NULL;
+    		}   		
+    	}
+    	free(desc);
+    	desc = NULL;
+    }   	
 }
 
 #if 0




		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com




More information about the MPlayer-dev-eng mailing list