diff --git a/conversion/stringconversion.cpp b/conversion/stringconversion.cpp index 47878d2..5f8595b 100644 --- a/conversion/stringconversion.cpp +++ b/conversion/stringconversion.cpp @@ -416,18 +416,19 @@ string encodeBase64(const std::uint8_t *data, std::uint32_t dataSize) */ std::pair, std::uint32_t> decodeBase64(const char *encodedStr, const std::uint32_t strSize) { + if (!strSize) { + return std::make_pair(std::make_unique(0), 0); // early return to prevent clazy warning + } if (strSize % 4) { throw ConversionException("invalid size of base64"); } std::uint32_t decodedSize = (strSize / 4) * 3; const char *const end = encodedStr + strSize; - if (strSize) { - if (*(end - 1) == base64Pad) { - --decodedSize; - } - if (*(end - 2) == base64Pad) { - --decodedSize; - } + if (*(end - 1) == base64Pad) { + --decodedSize; + } + if (*(end - 2) == base64Pad) { + --decodedSize; } auto buffer = std::make_unique(decodedSize); auto *iter = buffer.get() - 1;