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
1 changed files with 4 additions and 1 deletions

View File

@ -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);