aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/tiffenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-17 03:03:39 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-17 03:03:39 +0100
commit3f1a58db6f7a35a86190ff5897cb424b03a97870 (patch)
tree807fdf06a433f180d120ddf22bfc755df514cad1 /libavcodec/tiffenc.c
parent597d709eb42ae0fbe9e4b97fb1a5c04544fdb04b (diff)
parentb143844ea0f6246e0d5a938d743e2e8a98453bec (diff)
downloadffmpeg-3f1a58db6f7a35a86190ff5897cb424b03a97870.tar.gz
Merge commit 'b143844ea0f6246e0d5a938d743e2e8a98453bec' into release/0.8
* commit 'b143844ea0f6246e0d5a938d743e2e8a98453bec': (22 commits) aacdec: Fix an off-by-one overwrite when switching to LTP profile from MAIN. vp6: properly fail on unsupported feature h264: Fix parameters to ff_er_add_slice() call flacenc: ensure the order is within the min/max range in LPC order search yuv4mpeg: reject unsupported codecs vp8: reset loopfilter delta values at keyframes. vp56: release frames on error vp56: make parse_header return standard error codes ivi_common: check that scan pattern is set before using it. Update RELEASE file for 0.7.7 tiffenc: Check av_malloc() results. mpegaudiodec: fix short_start calculation h264: avoid stuck buffer pointer in decode_nal_units yuv4mpeg: return proper error codes. smacker audio: sign-extend the initial 16-bit predicted value vf_pad: don't give up its own reference to the output buffer. avidec: return 0, not packet size from read_packet(). wmapro: prevent division by zero when sample rate is unspecified alsdec: fix number of decoded samples in first sub-block in BGMC mode. alsdec: remove dead assignments ... Conflicts: RELEASE libavformat/avidec.c libavformat/yuv4mpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiffenc.c')
-rw-r--r--libavcodec/tiffenc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 97e1dd38c4..a7a1a40dd1 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -305,6 +305,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
strip_sizes = av_mallocz(sizeof(*strip_sizes) * strips);
strip_offsets = av_mallocz(sizeof(*strip_offsets) * strips);
+ if (!strip_sizes || !strip_offsets) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
bytes_per_row = (((s->width - 1)/s->subsampling[0] + 1) * s->bpp
* s->subsampling[0] * s->subsampling[1] + 7) >> 3;
@@ -312,6 +316,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
yuv_line = av_malloc(bytes_per_row);
if (yuv_line == NULL){
av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
+ ret = AVERROR(ENOMEM);
goto fail;
}
}
@@ -324,6 +329,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
zlen = bytes_per_row * s->rps;
zbuf = av_malloc(zlen);
+ if (!zbuf) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
strip_offsets[0] = ptr - buf;
zn = 0;
for (j = 0; j < s->rps; j++) {
@@ -348,8 +357,13 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
} else
#endif
{
- if(s->compr == TIFF_LZW)
+ if (s->compr == TIFF_LZW) {
s->lzws = av_malloc(ff_lzw_encode_state_size);
+ if (!s->lzws) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ }
for (i = 0; i < s->height; i++) {
if (strip_sizes[i / s->rps] == 0) {
if(s->compr == TIFF_LZW){