[MPlayer-dev-eng] [PATCH] Problems with invalid font.desc

Daniel von Dincklage danielvd+mpl at cs.colorado.edu
Thu Jul 1 11:55:57 CEST 2004


Hi,

there seem to be some bugs in the loading of the fonts
if the font.desc file does not contain the expected
values. These bugs will cause a crash in sub.c, line 610
as they cause the font member of the vo-font-structure
not to be initialized, thus still containing -1.

a) If  no content in the descfile the fgets() loop in font_load.c
 will never be executed, the error therefore never be detected
 and a successful load assumed.
 (See patch 1)

b) There also seems to be a bug that, if one of these situations
appears hafter having fixed the bug, mplayer tries to use the
OSD font for the subtitles
(Path
 sub.:777 -> load_font_ft
 	(As no font, and we are trying with a font...)
 font_load_ft.c:1159 ->  read_font_desc_ft
 	(font_fontconfig == 0)
 This function tries to load the subtitle font (with the
 name ""), fails, and proceeds loading the OSD-Font instead.
 The latter function returns the font structure of the OSD-Font,
 which then is entered as vo_font, and then indexed in the
 font structure while displaying the subtitles, which yields -1,
 and subsequently causes a crash.)
 (See patch 2)
 [By its own, the patch will cause a repeated message indicating
  the error each time the osd is upated; probably one should move
  the load_font_ft out of vo_update_osd]

c) If the font.desc has a syntax error, mplayer will display
 a message, but will continue nevertheless even though the
 font structure is bogus. (See patch 3)

There also seems to be a small problem with free()'ing some
memory in the function read_font_desc when errors occur; (ie
desc and the fname and/or dn is not freed, also the file is
not closed at each error condition.) (However, fixing this
would require some more invasive change, which I'll do in
some days)

- Daniel

-- 
Daniel von Dincklage (danielvd at colorado.edu)
Definition of Progress:
Long ago, there were many intelligent people in front of dumb terminals.
Today, there are many dumb people in front of intelligent terminals.
-------------- next part --------------
--- save/font_load.c    2004-06-29 02:43:30.000000000 -0600
+++ font_load.c 2004-06-29 02:57:54.000000000 -0600
@@ -249,6 +249,12 @@
 }
 fclose(f);

+ if (first == 1) {
+   printf("%s is empty or a directory, ignoring\n", fname);
+   free(desc);
+   return NULL;
+ }
+
 //printf("font: pos of U = %d\n",desc->start[218]);

 for(i=0;i<=fontdb;i++){
-------------- next part --------------
--- save/font_load_ft.c	2004-06-29 04:15:05.000000000 -0600
+++ font_load_ft.c	2004-06-29 04:15:49.000000000 -0600
@@ -1007,7 +1007,8 @@
     err = load_sub_face(fname, &face);
     if (err) {
 	mp_msg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n");
-	goto gen_osd;
+       free_font_desc(desc);
+       return NULL;
     }
     desc->face_cnt++;
 
-------------- next part --------------
--- save/font_load.c    2004-06-29 02:43:30.000000000 -0600
+++ font_load.c 2004-06-29 02:59:02.000000000 -0600
@@ -245,6 +245,8 @@
       }
   }
   printf("Syntax error in font desc: %s\n",sor);
+  free(desc);
+  return NULL;

 }
 fclose(f);


More information about the MPlayer-dev-eng mailing list