]> git.sesse.net Git - vlc/blobdiff - src/input/subtitles.c
Add %T modifier to filename refs: #561
[vlc] / src / input / subtitles.c
index ed50b06d3e873cc3efe199e61590f204d4e375e9..41a814031c88d8083f03d5692db9612e44b53260 100644 (file)
@@ -62,7 +62,7 @@
 
 
 /**
- * The possible extentions for subtitle files we support
+ * The possible extensions for subtitle files we support
  */
 static const char * sub_exts[] = {  "utf", "utf8", "utf-8", "sub", "srt", "smi", "txt", "ssa", "idx", NULL };
 /* extensions from unsupported types */
@@ -272,10 +272,6 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
     char *f_dir = NULL, *f_fname = NULL, *f_fname_noext = NULL, *f_fname_trim = NULL;
     char *tmp = NULL;
 
-    char tmp_fname_noext[PATH_MAX];
-    char tmp_fname_trim[PATH_MAX];
-    char tmp_fname_ext[PATH_MAX];
-
     char **tmp_subdirs, **subdirs; /* list of subdirectories to look in */
 
     subfn *result = NULL; /* unsorted results */
@@ -366,6 +362,10 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
             {
                 char *psz_name = vlc_fix_readdir_charset( p_this,
                                                           ppsz_dir_content[a] );
+                char tmp_fname_noext[strlen( psz_name ) + 1];
+                char tmp_fname_trim[strlen( psz_name ) + 1];
+                char tmp_fname_ext[strlen( psz_name ) + 1];
+
                 int i_prio = 0;
 
                 if( psz_name == NULL )
@@ -420,14 +420,13 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
                                 "autodetected subtitle: %s with priority %d",
                                 psz_path, i_prio );
                         result[i_sub_count].priority = i_prio;
-                        result[i_sub_count].psz_fname = psz_path;
+                        result[i_sub_count].psz_fname = strdup( psz_path );
                         result[i_sub_count].psz_ext = strdup(tmp_fname_ext);
                         i_sub_count++;
                     }
                     else
                     {
                         msg_Dbg( p_this, "fopen failed" );
-                        free( psz_path );
                     }
                 }
                 if( i_sub_count >= MAX_SUBTITLE_FILES ) break;