[FFmpeg-cvslog] avutil/base64: Fix undefined NULL + 0

Andreas Rheinhardt git at videolan.org
Thu Apr 1 17:12:24 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Mar 26 16:03:27 2021 +0100| [bbf8431b1bb947bdb3c9cb34718879ad1fc4e1be] | committer: Andreas Rheinhardt

avutil/base64: Fix undefined NULL + 0

Affected the base64 FATE test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbf8431b1bb947bdb3c9cb34718879ad1fc4e1be
---

 libavutil/base64.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/base64.c b/libavutil/base64.c
index 25ae8c411c..a1316b9438 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -79,12 +79,16 @@ static const uint8_t map2[256] =
 int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
 {
     uint8_t *dst = out;
-    uint8_t *end = out + out_size;
+    uint8_t *end;
     // no sign extension
     const uint8_t *in = in_str;
     unsigned bits = 0xff;
     unsigned v;
 
+    if (!out)
+        goto validity_check;
+
+    end = out + out_size;
     while (end - dst > 3) {
         BASE64_DEC_STEP(0);
         BASE64_DEC_STEP(1);
@@ -108,6 +112,7 @@ int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
             *dst++ = v;
         in += 4;
     }
+validity_check:
     while (1) {
         BASE64_DEC_STEP(0);
         in++;
@@ -126,7 +131,7 @@ out2:
     *dst++ = v >> 4;
 out1:
 out0:
-    return bits & 1 ? AVERROR_INVALIDDATA : dst - out;
+    return bits & 1 ? AVERROR_INVALIDDATA : out ? dst - out : 0;
 }
 
 /*****************************************************************************



More information about the ffmpeg-cvslog mailing list