[FFmpeg-devel] [PATCH 1/2] ass: use av_asprintf() instead of a temporary stack buffer.

Clément Bœsch ubitux at gmail.com
Sun Jan 29 15:03:23 CET 2012


---
Note: subtitle_header is not supposed to be already allocated, right?
---
 libavcodec/ass.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index cb0babf..8c94d72 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -29,9 +29,7 @@ int ff_ass_subtitle_header(AVCodecContext *avctx,
                            int bold, int italic, int underline,
                            int alignment)
 {
-    char header[512];
-
-    snprintf(header, sizeof(header),
+    avctx->subtitle_header = av_asprintf(
              "[Script Info]\r\n"
              "ScriptType: v4.00+\r\n"
              "\r\n"
@@ -44,7 +42,6 @@ int ff_ass_subtitle_header(AVCodecContext *avctx,
              font, font_size, color, color, back_color, back_color,
              -bold, -italic, -underline, alignment);
 
-    avctx->subtitle_header = av_strdup(header);
     if (!avctx->subtitle_header)
         return AVERROR(ENOMEM);
     avctx->subtitle_header_size = strlen(avctx->subtitle_header);
-- 
1.7.8.4



More information about the ffmpeg-devel mailing list