diff options
Diffstat (limited to 'subreader.c')
-rw-r--r-- | subreader.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/subreader.c b/subreader.c index a6b40ac3ec..d89e7be826 100644 --- a/subreader.c +++ b/subreader.c @@ -20,6 +20,7 @@ #include "subreader.h" #include "stream/stream.h" #include "libavutil/common.h" +#include "libavutil/avstring.h" #ifdef CONFIG_ENCA #include <enca.h> @@ -990,8 +991,7 @@ static subtitle *sub_read_line_jacosub(stream_t* st, subtitle * current) if (!stream_read_line(st, directive, LINE_LEN)) return NULL; trail_space(directive); - strncat(line2, directive, - (LINE_LEN > 511) ? LINE_LEN : 511); + av_strlcat(line2, directive, LINE_LEN); break; } default: @@ -1338,7 +1338,7 @@ const char* guess_cp(stream_t *st, const char *preferred_language, const char *f sub_data* sub_read_file (char *filename, float fps) { stream_t* fd; int n_max, n_first, i, j, sub_first, sub_orig; - subtitle *first, *second, *sub, *return_sub; + subtitle *first, *second, *sub, *return_sub, *alloced_sub = NULL; sub_data *subt_data; int uses_time = 0, sub_num = 0, sub_errs = 0; struct subreader sr[]= @@ -1401,6 +1401,7 @@ sub_data* sub_read_file (char *filename, float fps) { } #ifdef CONFIG_SORTSUB + alloced_sub = sub = malloc(sizeof(subtitle)); //This is to deal with those formats (AQT & Subrip) which define the end of a subtitle //as the beginning of the following @@ -1429,6 +1430,7 @@ sub_data* sub_read_file (char *filename, float fps) { subcp_close(); #endif if ( first ) free(first); + free(alloced_sub); return NULL; } // Apply any post processing that needs recoding first @@ -1481,6 +1483,7 @@ sub_data* sub_read_file (char *filename, float fps) { #ifdef CONFIG_ICONV subcp_close(); #endif + free(alloced_sub); // printf ("SUB: Subtitle format %s time.\n", uses_time?"uses":"doesn't use"); mp_msg(MSGT_SUBREADER, MSGL_V,"SUB: Read %i subtitles, %i bad line(s).\n", @@ -2251,15 +2254,15 @@ void dump_sami(sub_data* subd, float fps) { void sub_free( sub_data * subd ) { - int i; + int i, j; if ( !subd ) return; - if (subd->subtitles) { - for (i=0; i < subd->subtitles->lines; i++) free( subd->subtitles->text[i] ); - free( subd->subtitles ); - } - if (subd->filename) free( subd->filename ); + for (i = 0; i < subd->sub_num; i++) + for (j = 0; j < subd->subtitles[i].lines; j++) + free( subd->subtitles[i].text[j] ); + free( subd->subtitles ); + free( subd->filename ); free( subd ); } |