Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2016-06-27 03:08:53 +0300
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-06-29 22:25:42 +0300
commitd8f3b0fb584677d4882e3a2d7c28f8b15c7319f5 (patch)
tree91eb4ff70667575274abe1237709b2ebd731e0ed /libavcodec
parenteeb6849cedac099d41feb482da581f4059c63ca7 (diff)
targaenc: Move size check to initialization function
In case of bogus input, fail early at codec initialization, rather than at the encode function.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/targaenc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 204ecfeac7..f0cee38542 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -89,10 +89,6 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int bpp, picsize, datasize = -1, ret;
uint8_t *out;
- if(avctx->width > 0xffff || avctx->height > 0xffff) {
- av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
- return AVERROR(EINVAL);
- }
picsize = av_image_get_buffer_size(avctx->pix_fmt,
avctx->width, avctx->height, 1);
if ((ret = ff_alloc_packet(pkt, picsize + 45)) < 0) {
@@ -167,6 +163,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
static av_cold int targa_encode_init(AVCodecContext *avctx)
{
+ if (avctx->width > 0xffff || avctx->height > 0xffff) {
+ av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
+ return AVERROR(EINVAL);
+ }
+
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->key_frame = 1;