[FFmpeg-cvslog] r21720 - in branches/0.5: . libavcodec/vp3.c
siretart
subversion
Tue Feb 9 20:31:04 CET 2010
Author: siretart
Date: Tue Feb 9 20:31:04 2010
New Revision: 21720
Log:
Make sure that all memory allocations succeed.
Based on 28_theora_malloc_checks.patch from the Google Chrome team.
backport r20008 by melanson
Modified:
branches/0.5/ (props changed)
branches/0.5/libavcodec/vp3.c
Modified: branches/0.5/libavcodec/vp3.c
==============================================================================
--- branches/0.5/libavcodec/vp3.c Tue Feb 9 20:26:47 2010 (r21719)
+++ branches/0.5/libavcodec/vp3.c Tue Feb 9 20:31:04 2010 (r21720)
@@ -43,6 +43,8 @@
#define FRAGMENT_PIXELS 8
+static av_cold int vp3_decode_end(AVCodecContext *avctx);
+
typedef struct Coeff {
struct Coeff *next;
DCTELEM coeff;
@@ -1684,6 +1686,11 @@ static av_cold int vp3_decode_init(AVCod
s->coeffs = av_malloc(s->fragment_count * sizeof(Coeff) * 65);
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_initialized = 0;
+ if (!s->superblock_coding || !s->all_fragments || !s->coeff_counts ||
+ !s->coeffs || !s->coded_fragment_list) {
+ vp3_decode_end(avctx);
+ return -1;
+ }
if (!s->theora_tables)
{
@@ -1784,6 +1791,11 @@ static av_cold int vp3_decode_init(AVCod
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
s->macroblock_coding = av_malloc(s->macroblock_count + 1);
+ if (!s->superblock_fragments || !s->superblock_macroblocks ||
+ !s->macroblock_fragments || !s->macroblock_coding) {
+ vp3_decode_end(avctx);
+ return -1;
+ }
init_block_mapping(s);
for (i = 0; i < 3; i++) {
More information about the ffmpeg-cvslog
mailing list