summaryrefslogtreecommitdiff
path: root/libavcodec/vp8.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-15 13:10:37 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-15 13:10:48 +0100
commit9fb5a91c66934dab395ff32eb524a3dbe08b53d8 (patch)
treec81542e7d48c8e7bf3b248a09b86a227c68ce023 /libavcodec/vp8.c
parenteb215be9ce74f90d5aff304ad593f17a313f71fd (diff)
parent014b6b416fec89777cb9cff61bcf7896eaf7cf39 (diff)
Merge commit '014b6b416fec89777cb9cff61bcf7896eaf7cf39'
* commit '014b6b416fec89777cb9cff61bcf7896eaf7cf39': vp8: improve memory allocation checks Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vp8.c')
-rw-r--r--libavcodec/vp8.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 6ad26f3a7b..5d3123d4c2 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -176,19 +176,25 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
s->top_border = av_mallocz((s->mb_width + 1) * sizeof(*s->top_border));
s->thread_data = av_mallocz(MAX_THREADS * sizeof(VP8ThreadData));
+ if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
+ !s->thread_data || (!s->intra4x4_pred_mode_top && !s->mb_layout)) {
+ free_buffers(s);
+ return AVERROR(ENOMEM);
+ }
+
for (i = 0; i < MAX_THREADS; i++) {
s->thread_data[i].filter_strength =
av_mallocz(s->mb_width * sizeof(*s->thread_data[0].filter_strength));
+ if (!s->thread_data[i].filter_strength) {
+ free_buffers(s);
+ return AVERROR(ENOMEM);
+ }
#if HAVE_THREADS
pthread_mutex_init(&s->thread_data[i].lock, NULL);
pthread_cond_init(&s->thread_data[i].cond, NULL);
#endif
}
- if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
- (!s->intra4x4_pred_mode_top && !s->mb_layout))
- return AVERROR(ENOMEM);
-
s->macroblocks = s->macroblocks_base + 1;
return 0;