[MPlayer-cvslog] CVS: main mencoder.c, 1.287, 1.288 mplayer.c, 1.846, 1.847 subreader.c, 1.143, 1.144

Reimar Döffinger CVS syncmail at mplayerhq.hu
Wed Jun 1 11:01:43 CEST 2005


CVS change done by Reimar Döffinger CVS

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

Modified Files:
	mencoder.c mplayer.c subreader.c 
Log Message:
strdup subtitle filename at a more appropriate place, fixing memleaks and
double frees.


Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -r1.287 -r1.288
--- mencoder.c	24 May 2005 19:46:44 -0000	1.287
+++ mencoder.c	1 Jun 2005 09:01:41 -0000	1.288
@@ -591,8 +591,17 @@
     if(!subdata) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name[0]);
   } else
   if(sub_auto) { // auto load sub file ...
-    subdata=sub_read_file( filename ? sub_filenames( get_path("sub/"), filename )[0]
-	                              : "default.sub", sh_video->fps );
+    char **tmp = NULL;
+    int i = 0;
+    if (filename) {
+      char *psub = get_path( "sub/" );
+      tmp = sub_filenames((psub ? psub : ""), filename);
+      free(psub);
+    }
+    subdata=sub_read_file(tmp ? tmp[0] : "default.sub", sh_video->fps);
+    while (tmp && tmp[i])
+      free(tmp[i++]);
+    free(tmp);
   }
 #endif	
 

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.846
retrieving revision 1.847
diff -u -r1.846 -r1.847
--- mplayer.c	28 May 2005 21:28:40 -0000	1.846
+++ mplayer.c	1 Jun 2005 09:01:41 -0000	1.847
@@ -1914,18 +1914,18 @@
   if(sub_auto) { // auto load sub file ...
     char *psub = get_path( "sub/" );
     char **tmp = sub_filenames((psub ? psub : ""), filename);
-    char **tmp2 = tmp;
+    int i = 0;
     free(psub); // release the buffer created by get_path() above
-    while (*tmp2)
-        add_subtitles (*tmp2++, sh_video->fps, 0);
+    while (tmp[i]) {
+        add_subtitles (tmp[i], sh_video->fps, 0);
+        free(tmp[i++]);
+    }
     free(tmp);
     if (set_of_sub_size == 0)
     {
         add_subtitles (mem_ptr=get_path("default.sub"), sh_video->fps, 1);
     free(mem_ptr); // release the buffer created by get_path()
     }
-    if (set_of_sub_size > 0)
-        add_subtitles (NULL, sh_video->fps, 1);
   }
   if (set_of_sub_size > 0)  {
       // setup global sub numbering

Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -r1.143 -r1.144
--- subreader.c	24 May 2005 08:42:20 -0000	1.143
+++ subreader.c	1 Jun 2005 09:01:41 -0000	1.144
@@ -1350,7 +1350,6 @@
 #endif
 
 sub_data* sub_read_file (char *filename, float fps) {
-        //filename is assumed to be malloc'ed,  free() is used in sub_free()
     FILE *fd;
     int n_max, n_first, i, j, sub_first, sub_orig;
     subtitle *first, *second, *sub, *return_sub;
@@ -1718,7 +1717,7 @@
 }
     if (return_sub == NULL) return NULL;
     subt_data = (sub_data *)malloc(sizeof(sub_data));
-    subt_data->filename = filename;
+    subt_data->filename = strdup(filename);
     subt_data->sub_uses_time = uses_time;
     subt_data->sub_num = sub_num;
     subt_data->sub_errs = sub_errs;




More information about the MPlayer-cvslog mailing list