diff mencoder.c @ 15603:2d1ad16b6021

strdup subtitle filename at a more appropriate place, fixing memleaks and double frees.
author reimar
date Wed, 01 Jun 2005 09:01:41 +0000
parents 1c1c7cd29707
children 9b4bbb6098f6
line wrap: on
line diff
--- a/mencoder.c	Tue May 31 22:35:40 2005 +0000
+++ b/mencoder.c	Wed Jun 01 09:01:41 2005 +0000
@@ -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