diff mbox series

[FFmpeg-devel,2/2] avformat/jpegxl_probe: Forward error codes

Message ID 20230607234810.9283-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/2] avformat/jpegxl_probe: check length instead of blindly reading | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Michael Niedermayer June 7, 2023, 11:48 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/jpegxl_probe.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/jpegxl_probe.c b/libavformat/jpegxl_probe.c
index e15e9eee49..88492cb772 100644
--- a/libavformat/jpegxl_probe.c
+++ b/libavformat/jpegxl_probe.c
@@ -261,8 +261,8 @@  int ff_jpegxl_verify_codestream_header(const uint8_t *buf, int buflen, int valid
     if (get_bits_long(gb, 16) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE)
         return -1;
 
-    if (jpegxl_read_size_header(gb) < 0 && validate_level)
-        return -1;
+    if ((ret = jpegxl_read_size_header(gb)) < 0 && validate_level)
+        return ret;
 
     all_default = get_bits1(gb);
     if (!all_default)
@@ -281,8 +281,9 @@  int ff_jpegxl_verify_codestream_header(const uint8_t *buf, int buflen, int valid
 
         /* preview header */
         if (get_bits1(gb)) {
-            if (jpegxl_read_preview_header(gb) < 0)
-                return -1;
+            ret = jpegxl_read_preview_header(gb);
+            if (ret < 0)
+                return ret;
         }
 
         /* animation header */
@@ -308,8 +309,9 @@  int ff_jpegxl_verify_codestream_header(const uint8_t *buf, int buflen, int valid
         if (num_extra_channels > 4 && validate_level)
             return -1;
         for (uint32_t i = 0; i < num_extra_channels; i++) {
-            if (jpegxl_read_extra_channel_info(gb, validate_level) < 0)
-                return -1;
+            ret = jpegxl_read_extra_channel_info(gb, validate_level);
+            if (ret < 0)
+                return ret;
             if (get_bits_left(gb) < 1)
                 return AVERROR_INVALIDDATA;
         }