From 32d8271556c002b06642653e5b8a7b32bec3a310 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:10:03 +0800 Subject: [PATCH] fix: neu_decode64 on empty string --- src/utils/base64.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/base64.c b/src/utils/base64.c index c11e5af6..4dd131a2 100644 --- a/src/utils/base64.c +++ b/src/utils/base64.c @@ -40,6 +40,10 @@ size_t calcDecodeLength(const char *b64input) { // Calculates the length of a decoded string size_t len = strlen(b64input), padding = 0; + if (0 == len) { + return 0; + } + if (b64input[len - 1] == '=' && b64input[len - 2] == '=') // last two chars are = padding = 2;