Changeset 014b6b41 in ffmpeg


Ignore:
Timestamp:
Jan 15, 2015, 12:25:07 AM (10 years ago)
Author:
Vittorio Giovara <vittorio.giovara@gmail.com>
Branches:
master
Children:
8a9641a6, 9fb5a91
Parents:
54bc15d5
git-author:
Vittorio Giovara <vittorio.giovara@gmail.com> (12/17/14 15:02:08)
git-committer:
Vittorio Giovara <vittorio.giovara@gmail.com> (01/15/15 00:25:07)
Message:

vp8: improve memory allocation checks

Check memory earlier, check one more allocation and clean up on error.

CC: libav-stable@libav.org
Bug-Id: CID 1257773

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libavcodec/vp8.c

    r54bc15d5 r014b6b41  
    169169    s->thread_data = av_mallocz(MAX_THREADS * sizeof(VP8ThreadData));
    170170
     171    if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
     172        !s->thread_data || (!s->intra4x4_pred_mode_top && !s->mb_layout)) {
     173        free_buffers(s);
     174        return AVERROR(ENOMEM);
     175    }
     176
    171177    for (i = 0; i < MAX_THREADS; i++) {
    172178        s->thread_data[i].filter_strength =
    173179            av_mallocz(s->mb_width * sizeof(*s->thread_data[0].filter_strength));
     180        if (!s->thread_data[i].filter_strength) {
     181            free_buffers(s);
     182            return AVERROR(ENOMEM);
     183        }
    174184#if HAVE_THREADS
    175185        pthread_mutex_init(&s->thread_data[i].lock, NULL);
     
    177187#endif
    178188    }
    179 
    180     if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
    181         (!s->intra4x4_pred_mode_top && !s->mb_layout))
    182         return AVERROR(ENOMEM);
    183189
    184190    s->macroblocks = s->macroblocks_base + 1;
Note: See TracChangeset for help on using the changeset viewer.