diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-01-15 14:26:55 +0100 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-01-17 20:16:35 +0100 |
commit | 3b55429d5692dd782d8b3ce6a19819305157d1b8 (patch) | |
tree | 489c7014c1e3843253cb17e53f3d3950967b312f /libavcodec/mjpegdec.c | |
parent | a129622390fca8a298c3b121f42b2d15910b9b22 (diff) | |
download | ffmpeg-3b55429d5692dd782d8b3ce6a19819305157d1b8.tar.gz |
Add and use av_fast_padded_malloc.
The same as av_fast_malloc but uses av_mallocz and keeps extra
always-0 padding.
This does not mean the memory will be 0-initialized after each call,
but actually only after each growth of the buffer.
However this makes sure that
a) all data anywhere in the buffer is always initialized
b) the padding is always 0
c) the user does not have to bother with adding the padding themselves
Fixes another valgrind warning about use of uninitialized data,
this time with fate-vsynth1-jpegls.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r-- | libavcodec/mjpegdec.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index ad78b4cc0d..2abfea0d6e 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1474,13 +1474,9 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s, int start_code; start_code = find_marker(buf_ptr, buf_end); - if ((buf_end - *buf_ptr) > s->buffer_size) { - av_free(s->buffer); - s->buffer_size = buf_end - *buf_ptr; - s->buffer = av_malloc(s->buffer_size + FF_INPUT_BUFFER_PADDING_SIZE); - av_log(s->avctx, AV_LOG_DEBUG, - "buffer too small, expanding to %d bytes\n", s->buffer_size); - } + av_fast_padded_malloc(&s->buffer, &s->buffer_size, buf_end - *buf_ptr); + if (!s->buffer) + return AVERROR(ENOMEM); /* unescape buffer of SOS, use special treatment for JPEG-LS */ if (start_code == SOS && !s->ls) { |