diff mbox series

[FFmpeg-devel,28/36] avcodec/mjpega_dump_header_bsf: Miscellaneous improvements

Message ID 20200530160541.29517-28-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/36] avcodec/vp9_superframe_bsf: Check for existence of data before reading it | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 30, 2020, 4:05 p.m. UTC
1. Instead of comparing two values read via AV_RL32 one can read both
via AV_RN32 and compare the values.
2. Errors like AVERROR(ENOMEM) from failed allocations are now always
forwarded.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mjpega_dump_header_bsf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c
index 4ea55e88ba..98fd2f9250 100644
--- a/libavcodec/mjpega_dump_header_bsf.c
+++ b/libavcodec/mjpega_dump_header_bsf.c
@@ -77,7 +77,7 @@  static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt)
                 return 0;
             }
             case APP1:
-                if (i + 12U <= pkt->size && AV_RL32(pkt->data + i + 8) == AV_RL32("mjpg")) {
+                if (i + 12U <= pkt->size && AV_RN32(pkt->data + i + 8) == AV_RN32("mjpg")) {
                     av_log(ctx, AV_LOG_ERROR, "bitstream already formatted\n");
                     return 0;
                 }
@@ -85,9 +85,10 @@  static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt)
         }
     }
     av_log(ctx, AV_LOG_ERROR, "No valid SOS marker in bitstream\n");
+    ret = AVERROR_INVALIDDATA;
 fail:
     av_packet_unref(pkt);
-    return AVERROR_INVALIDDATA;
+    return ret;
 }
 
 static const enum AVCodecID codec_ids[] = {