mirror of https://git.ffmpeg.org/ffmpeg.git
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:
parent
530c1441fd
commit
f401792595
|
@ -398,8 +398,11 @@ static av_cold int init(AVFilterContext *ctx)
|
||||||
return err;
|
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);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
memcpy(s->text, textbuf, textbuf_size);
|
memcpy(s->text, textbuf, textbuf_size);
|
||||||
s->text[textbuf_size] = 0;
|
s->text[textbuf_size] = 0;
|
||||||
av_file_unmap(textbuf, textbuf_size);
|
av_file_unmap(textbuf, textbuf_size);
|
||||||
|
|
Loading…
Reference in New Issue