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. --- libavcodec/assenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavcodec/assenc.c') diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index 7ed21eedbc..50b89c00d6 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -28,11 +28,12 @@ static av_cold int ass_encode_init(AVCodecContext *avctx) { - avctx->extradata = av_malloc(avctx->subtitle_header_size); + avctx->extradata = av_malloc(avctx->subtitle_header_size + 1); if (!avctx->extradata) return AVERROR(ENOMEM); memcpy(avctx->extradata, avctx->subtitle_header, avctx->subtitle_header_size); avctx->extradata_size = avctx->subtitle_header_size; + avctx->extradata[avctx->extradata_size] = 0; return 0; } -- cgit v1.2.3