Commit 50b4dbf6 authored by Philip Langdale's avatar Philip Langdale

ass subtitles: Fix valgrind warnings.

We're now running some of this code through valgrind for the first
time, and a few warnings showed up stemming from two problems.

1) The ASS code assumes the subtitle header is null terminated, but
it wasn't, and passing the size down doesn't look like fun, so I
added a terminator

2) The code wasn't freeing all of its state.
Signed-off-by: 's avatarPhilip Langdale <philipl@overt.org>
parent c30f53e4
...@@ -3366,7 +3366,8 @@ static int transcode_init(void) ...@@ -3366,7 +3366,8 @@ static int transcode_init(void)
if ((ist = get_input_stream(ost))) if ((ist = get_input_stream(ost)))
dec = ist->st->codec; dec = ist->st->codec;
if (dec && dec->subtitle_header) { if (dec && dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); /* ASS code assumes this buffer is null terminated so add extra byte. */
ost->st->codec->subtitle_header = av_mallocz(dec->subtitle_header_size + 1);
if (!ost->st->codec->subtitle_header) { if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto dump_format; goto dump_format;
......
...@@ -352,8 +352,10 @@ void ff_ass_split_free(ASSSplitContext *ctx) ...@@ -352,8 +352,10 @@ void ff_ass_split_free(ASSSplitContext *ctx)
{ {
if (ctx) { if (ctx) {
int i; int i;
for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++) {
free_section(ctx, &ass_sections[i]); free_section(ctx, &ass_sections[i]);
av_freep(&(ctx->field_order[i]));
}
av_free(ctx); av_free(ctx);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment