diff options
author | Alex Converse <alex.converse@gmail.com> | 2012-04-12 18:10:57 -0700 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2012-04-13 09:49:13 -0700 |
commit | 99a335299ff3541f89e6e3be4b9ae84257288fcc (patch) | |
tree | 7015c738f9444a882db51c6452386b02df49d2ce /libavcodec | |
parent | 6555acad10a6593d91fb09c7c20bbb4ab335bc02 (diff) | |
download | ffmpeg-99a335299ff3541f89e6e3be4b9ae84257288fcc.tar.gz |
faxcompr: Check malloc results and unify return path
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/faxcompr.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index a0fa82551e..077e74030e 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -275,12 +275,17 @@ int ff_ccitt_unpack(AVCodecContext *avctx, { int j; GetBitContext gb; - int *runs, *ref, *runend; + int *runs, *ref = NULL, *runend; int ret; int runsize= avctx->width + 2; + int err = 0; runs = av_malloc(runsize * sizeof(runs[0])); ref = av_malloc(runsize * sizeof(ref[0])); + if (!runs || ! ref) { + err = AVERROR(ENOMEM); + goto fail; + } ref[0] = avctx->width; ref[1] = 0; ref[2] = 0; @@ -290,9 +295,8 @@ int ff_ccitt_unpack(AVCodecContext *avctx, if(compr == TIFF_G4){ ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(ret < 0){ - av_free(runs); - av_free(ref); - return -1; + err = -1; + goto fail; } }else{ int g3d1 = (compr == TIFF_G3) && !(opts & 1); @@ -313,7 +317,8 @@ int ff_ccitt_unpack(AVCodecContext *avctx, } dst += stride; } +fail: av_free(runs); av_free(ref); - return 0; + return err; } |