[MPlayer-dev-eng] [PATCH] make sub_read_file strdup the filename
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri May 27 16:57:38 CEST 2005
Hi,
since it is at the moment use incorrectly in mplayer.c and even in its
own "sample" code in subreader.c (not to mention that I hate the current
semantics), this patch makes sub_read_file strdup the filename for
storing it in subt_data.
It will make the memleak in mencoder.c a tiny bit bigger (where in
addition was also used incorrectly before well by passing "default"),
but compared to the leak caused by not freeing the results of get_path
and sub_filenames that's negligable.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.143
diff -u -r1.143 subreader.c
--- subreader.c 24 May 2005 08:42:20 -0000 1.143
+++ subreader.c 27 May 2005 14:47:51 -0000
@@ -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;
Index: Gui/interface.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/interface.c,v
retrieving revision 1.104
diff -u -r1.104 interface.c
--- Gui/interface.c 12 Feb 2005 16:05:10 -0000 1.104
+++ Gui/interface.c 27 May 2005 14:47:51 -0000
@@ -486,7 +486,7 @@
if ( name )
{
mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_LoadingSubtitles,name );
- subdata=sub_read_file( gstrdup( name ), guiIntfStruct.FPS );
+ subdata=sub_read_file( name, guiIntfStruct.FPS );
if ( !subdata ) mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_CantLoadSub,name );
sub_name = (malloc(2 * sizeof(char*))); //when mplayer will be restarted
sub_name[0] = strdup(name); //sub_name[0] will be read
More information about the MPlayer-dev-eng
mailing list