avcodec/jacosubdec: add some memory checks

pull/86/head
Clément Bœsch 10 years ago
parent d210c0e777
commit 4c85073044
  1. 9
      libavcodec/jacosubdec.c

@ -168,6 +168,7 @@ static void jacosub_to_ass(AVCodecContext *avctx, AVBPrint *dst, const char *src
static int jacosub_decode_frame(AVCodecContext *avctx, static int jacosub_decode_frame(AVCodecContext *avctx,
void *data, int *got_sub_ptr, AVPacket *avpkt) void *data, int *got_sub_ptr, AVPacket *avpkt)
{ {
int ret;
AVSubtitle *sub = data; AVSubtitle *sub = data;
const char *ptr = avpkt->data; const char *ptr = avpkt->data;
@ -176,7 +177,6 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
if (*ptr) { if (*ptr) {
AVBPrint buffer; AVBPrint buffer;
char *dec_sub;
// skip timers // skip timers
ptr = jss_skip_whitespace(ptr); ptr = jss_skip_whitespace(ptr);
@ -185,9 +185,10 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
av_bprint_init(&buffer, JSS_MAX_LINESIZE, JSS_MAX_LINESIZE); av_bprint_init(&buffer, JSS_MAX_LINESIZE, JSS_MAX_LINESIZE);
jacosub_to_ass(avctx, &buffer, ptr); jacosub_to_ass(avctx, &buffer, ptr);
av_bprint_finalize(&buffer, &dec_sub); ret = ff_ass_add_rect_bprint(sub, &buffer, avpkt->pts, avpkt->duration, 0);
ff_ass_add_rect(sub, dec_sub, avpkt->pts, avpkt->duration, 0); av_bprint_finalize(&buffer, NULL);
av_free(dec_sub); if (ret < 0)
return ret;
} }
end: end:

Loading…
Cancel
Save