diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-21 16:33:03 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-17 21:50:09 +0200 |
commit | cea2106fb2e1fc541691ab9b3fe54000aeb14f19 (patch) | |
tree | 0bb6c6495e45053cb69ac001d75a1d05fecd8409 | |
parent | c9c5bd8c89b6e3cc09e50c3b053cd8a083fbddc6 (diff) | |
download | ffmpeg-cea2106fb2e1fc541691ab9b3fe54000aeb14f19.tar.gz |
avcodec/h264_slice: More complete cleanup in h264_slice_header_init()
Fixes null pointer dereference
Fixes Ticket3873
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 1fa35e4352cc39894987e14de464e3d72b55739f)
Conflicts:
libavcodec/h264_slice.c
-rw-r--r-- | libavcodec/h264.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 37b9d34814..870aedd1e2 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3351,7 +3351,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) ret = ff_h264_alloc_tables(h); if (ret < 0) { av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n"); - return ret; + goto fail; } if (nb_slices > MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) { @@ -3370,14 +3370,16 @@ static int h264_slice_header_init(H264Context *h, int reinit) ret = context_init(h); if (ret < 0) { av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n"); - return ret; + goto fail; } } else { for (i = 1; i < h->slice_context_count; i++) { H264Context *c; c = h->thread_context[i] = av_mallocz(sizeof(H264Context)); - if (!c) - return AVERROR(ENOMEM); + if (!c) { + ret = AVERROR(ENOMEM); + goto fail; + } c->avctx = h->avctx; if (CONFIG_ERROR_RESILIENCE) { c->dsp = h->dsp; @@ -3416,13 +3418,17 @@ static int h264_slice_header_init(H264Context *h, int reinit) for (i = 0; i < h->slice_context_count; i++) if ((ret = context_init(h->thread_context[i])) < 0) { av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n"); - return ret; + goto fail; } } h->context_initialized = 1; return 0; +fail: + free_tables(h, 0); + h->context_initialized = 0; + return ret; } int ff_set_ref_count(H264Context *h) |