From 36e61e24e7ac737b38c4382d439329352d9e0c29 Mon Sep 17 00:00:00 2001 From: Clément Bœsch Date: Sat, 29 Dec 2012 22:09:59 +0100 Subject: lavc: add ff_bprint_to_extradata() helper and use it. This commit also makes sure the extradata and subtitle_header are NUL terminated, without taking into account the trailing '\0' in account in the size. At the same time, it should fix 'warning: dereferencing type-punned pointer will break strict-aliasing rules' warning for compilers who don't consider uint8_t** and char** compatibles. --- libavformat/subviewerdec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'libavformat/subviewerdec.c') diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c index 7691d82768..8ecc928817 100644 --- a/libavformat/subviewerdec.c +++ b/libavformat/subviewerdec.c @@ -27,6 +27,7 @@ #include "avformat.h" #include "internal.h" #include "subtitles.h" +#include "libavcodec/internal.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/intreadwrite.h" @@ -99,12 +100,9 @@ static int subviewer_read_header(AVFormatContext *s) av_bprintf(&header, "%s", line); if (!strncmp(line, "[END INFORMATION]", 17) || !strncmp(line, "[SUBTITLE]", 10)) { /* end of header */ - av_bprint_finalize(&header, (char **)&st->codec->extradata); - if (!st->codec->extradata) { - res = AVERROR(ENOMEM); + res = ff_bprint_to_extradata(st->codec, &header); + if (res < 0) goto end; - } - st->codec->extradata_size = header.len + 1; } else if (strncmp(line, "[INFORMATION]", 13)) { /* assume file metadata at this point */ int i, j = 0; -- cgit v1.2.3