From d828b454f0c3d6193c8c955fab36d628c0f856a1 Mon Sep 17 00:00:00 2001 From: huahang Date: Mon, 19 Apr 2021 10:52:36 +0800 Subject: [PATCH] Fix a null pointer exception in modp_b64_decode() Fix https://github.com/client9/stringencoders/issues/55 --- src/modp_b64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modp_b64.c b/src/modp_b64.c index 41ed188..8d37d3b 100644 --- a/src/modp_b64.c +++ b/src/modp_b64.c @@ -166,6 +166,9 @@ size_t modp_b64_decode(char* dest, const char* src, size_t len) size_t modp_b64_decode(char* dest, const char* src, size_t len) { + if (len == 0) + return 0; + size_t i; size_t leftover; size_t chunks; @@ -176,9 +179,6 @@ size_t modp_b64_decode(char* dest, const char* src, size_t len) const uint32_t* srcInt = (const uint32_t*)src; uint32_t y = *srcInt++; - if (len == 0) - return 0; - #ifdef DOPAD /* * if padding is used, then the message must be at least