1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-28 07:53:47 +02:00

vf_drawtext: Do not leak the mmapped textfile

And validate its size while at it.

CC: libav-stable@libav.org
Bug-Id: CID 1244189
This commit is contained in:
Luca Barbato 2014-10-17 10:07:10 +01:00 committed by Vittorio Giovara
parent 530c1441fd
commit f401792595

View File

@ -398,8 +398,11 @@ static av_cold int init(AVFilterContext *ctx)
return err;
}
if (!(s->text = av_malloc(textbuf_size+1)))
if (textbuf_size > SIZE_MAX - 1 ||
!(s->text = av_malloc(textbuf_size + 1))) {
av_file_unmap(textbuf, textbuf_size);
return AVERROR(ENOMEM);
}
memcpy(s->text, textbuf, textbuf_size);
s->text[textbuf_size] = 0;
av_file_unmap(textbuf, textbuf_size);