diff mbox series

[FFmpeg-devel,4/4] avcodec/dvdsubenc: return error if canvas_size is too small for subtitle render

Message ID 1652280498-10408-4-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 94968dbc1116e23cb658c09538e9bce52b63d654
Headers show
Series [FFmpeg-devel,1/4] remove sccenc dependency on subtitles | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Limin Wang May 11, 2022, 2:48 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/dvdsubenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Limin Wang May 18, 2022, 1:42 p.m. UTC | #1
On Wed, May 11, 2022 at 10:48:18PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/dvdsubenc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
> index fc3b7d1816..d29db7d49c 100644
> --- a/libavcodec/dvdsubenc.c
> +++ b/libavcodec/dvdsubenc.c
> @@ -376,6 +376,12 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
>      x2 = vrect.x + vrect.w - 1;
>      y2 = vrect.y + vrect.h - 1;
>  
> +    if (x2 > avctx->width || y2 > avctx->height) {
> +        av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) for render\n",
> +               avctx->width, avctx->height, x2, y2);
> +        ret = AVERROR(EINVAL);;
> +        goto fail;
> +    }
>      *q++ = 0x05;
>      // x1 x2 -> 6 nibbles
>      *q++ = vrect.x >> 4;
> -- 
> 2.35.1
> 
will apply the patchset 1,3,4 tomorrow if no other comments.
diff mbox series

Patch

diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index fc3b7d1816..d29db7d49c 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -376,6 +376,12 @@  static int encode_dvd_subtitles(AVCodecContext *avctx,
     x2 = vrect.x + vrect.w - 1;
     y2 = vrect.y + vrect.h - 1;
 
+    if (x2 > avctx->width || y2 > avctx->height) {
+        av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) for render\n",
+               avctx->width, avctx->height, x2, y2);
+        ret = AVERROR(EINVAL);;
+        goto fail;
+    }
     *q++ = 0x05;
     // x1 x2 -> 6 nibbles
     *q++ = vrect.x >> 4;