diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-01-30 18:35:35 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-02-01 14:37:47 -0500 |
commit | 0880503fbbd68bf6b1352488944020e3ec35c2e4 (patch) | |
tree | a995eb6c05aa37a131633fe24ee1aeba9b4e5595 /libavcodec/mjpegdec.c | |
parent | 2f4b9021a18312685f93768688e5e27a8ccd70a3 (diff) | |
download | ffmpeg-0880503fbbd68bf6b1352488944020e3ec35c2e4.tar.gz |
mjpegdec: use av_fast_padded_malloc()
also check for allocation failure
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
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 d6ed43bbaa..48a872bdb7 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1359,13 +1359,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) { |