Browse Source

Bug fix: Failure when reading empty certificate authority configuration

(cherry picked from commit 9fefb2536c9ed5434a468bfcf097d2fd57b51c0c)

Source commit: 105088f20f028f01afdd031953d8bb35303a9120
Martin Prikryl 3 months ago
parent
commit
fe44a85b14
1 changed files with 8 additions and 3 deletions
  1. 8 3
      source/core/Common.cpp

+ 8 - 3
source/core/Common.cpp

@@ -510,9 +510,14 @@ UnicodeString EncodeStrToBase64(const RawByteString & Str)
 RawByteString DecodeBase64ToStr(const UnicodeString & Str)
 {
   TBytes Bytes = DecodeBase64(Str);
-  // This might be the same as TEncoding::ASCII->GetString.
-  // const_cast: The operator[] const is (badly?) implemented to return by value
-  return RawByteString(reinterpret_cast<const char *>(&const_cast<TBytes &>(Bytes)[0]), Bytes.Length);
+  RawByteString Result;
+  if (Bytes.Length > 0)
+  {
+    // This might be the same as TEncoding::ASCII->GetString.
+    // const_cast: The operator[] const is (badly?) implemented to return by value
+    Result = RawByteString(reinterpret_cast<const char *>(&const_cast<TBytes &>(Bytes)[0]), Bytes.Length);
+  }
+  return Result;
 }
 //---------------------------------------------------------------------------
 UnicodeString Base64ToUrlSafe(const UnicodeString & S)