summaryrefslogtreecommitdiff
path: root/libavcodec/pngenc.c
diff options
context:
space:
mode:
authorDonny Yang <work@kota.moe>2015-03-29 11:05:42 +0000
committerMichael Niedermayer <michaelni@gmx.at>2015-03-29 17:59:08 +0200
commit68ede913d03359a617e256c22ae3d976604269b5 (patch)
tree6e8d46a1a1d4837e445664bc9acb6e0831bc0297 /libavcodec/pngenc.c
parent7b060a96ad8a6a635d33011b9b5fbb79adcf31d8 (diff)
downloadffmpeg-68ede913d03359a617e256c22ae3d976604269b5.tar.gz
png: Return slightly more meaningful error codes
Signed-off-by: Donny Yang <work@kota.moe> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngenc.c')
-rw-r--r--libavcodec/pngenc.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index d6233d0dc4..946b816f0f 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -373,19 +373,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->bytestream_end = pkt->data + pkt->size;
crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED));
- if (!crow_base)
- goto fail;
+ if (!crow_base) {
+ ret = AVERROR(ENOMEM);
+ goto the_end;
+ }
// pixel data should be aligned, but there's a control byte before it
crow_buf = crow_base + 15;
if (is_progressive) {
progressive_buf = av_malloc(row_size + 1);
- if (!progressive_buf)
- goto fail;
- }
- if (is_progressive) {
top_buf = av_malloc(row_size + 1);
- if (!top_buf)
- goto fail;
+ if (!progressive_buf || !top_buf) {
+ ret = AVERROR(ENOMEM);
+ goto the_end;
+ }
}
/* write png header */
@@ -501,7 +501,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (ret == Z_STREAM_END)
break;
} else {
- goto fail;
+ ret = -1;
+ goto the_end;
}
}
png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
@@ -517,9 +518,6 @@ the_end:
av_freep(&top_buf);
deflateEnd(&s->zstream);
return ret;
-fail:
- ret = -1;
- goto the_end;
}
static av_cold int png_enc_init(AVCodecContext *avctx)