targaenc: Move size check to initialization function
In case of bogus input, fail early at codec initialization, rather than at the encode function.
This commit is contained in:
parent
eeb6849ced
commit
d8f3b0fb58
@ -89,10 +89,6 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
int bpp, picsize, datasize = -1, ret;
|
int bpp, picsize, datasize = -1, ret;
|
||||||
uint8_t *out;
|
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,
|
picsize = av_image_get_buffer_size(avctx->pix_fmt,
|
||||||
avctx->width, avctx->height, 1);
|
avctx->width, avctx->height, 1);
|
||||||
if ((ret = ff_alloc_packet(pkt, picsize + 45)) < 0) {
|
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)
|
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
|
#if FF_API_CODED_FRAME
|
||||||
FF_DISABLE_DEPRECATION_WARNINGS
|
FF_DISABLE_DEPRECATION_WARNINGS
|
||||||
avctx->coded_frame->key_frame = 1;
|
avctx->coded_frame->key_frame = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user