diff mbox series

[FFmpeg-devel] av1dec: Don't crash if decoding of some frames have failed

Message ID 20241002082848.73792-1-martin@martin.st
State Accepted
Headers show
Series [FFmpeg-devel] av1dec: Don't crash if decoding of some frames have failed | 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

Martin Storsjö Oct. 2, 2024, 8:28 a.m. UTC
If decoding with hwaccel, but decoding fails, these pointers
are null at this point.
---
 libavcodec/av1dec.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Martin Storsjö Oct. 4, 2024, 3:11 p.m. UTC | #1
On Wed, 2 Oct 2024, Martin Storsjö wrote:

> If decoding with hwaccel, but decoding fails, these pointers
> are null at this point.
> ---
> libavcodec/av1dec.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index 6a9de07d16..bc4ef63e68 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -281,6 +281,8 @@ static void skip_mode_params(AV1DecContext *s)
>     forward_idx  = -1;
>     backward_idx = -1;
>     for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
> +        if (!s->ref[header->ref_frame_idx[i]].raw_frame_header)
> +            return;
>         ref_hint = s->ref[header->ref_frame_idx[i]].raw_frame_header->order_hint;
>         dist = get_relative_dist(seq, ref_hint, header->order_hint);
>         if (dist < 0) {
> -- 
> 2.39.5 (Apple Git-154)

OK'd by James on irc, will push later.

// Martin
diff mbox series

Patch

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 6a9de07d16..bc4ef63e68 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -281,6 +281,8 @@  static void skip_mode_params(AV1DecContext *s)
     forward_idx  = -1;
     backward_idx = -1;
     for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+        if (!s->ref[header->ref_frame_idx[i]].raw_frame_header)
+            return;
         ref_hint = s->ref[header->ref_frame_idx[i]].raw_frame_header->order_hint;
         dist = get_relative_dist(seq, ref_hint, header->order_hint);
         if (dist < 0) {