Base64DecodeClover cannot return not-NULL and DecodedSize=0 anymore.

This commit is contained in:
jief666 2020-09-04 13:52:05 +03:00
parent 0fd1dcbc18
commit f4e10b1a2a
1 changed files with 6 additions and 0 deletions

View File

@ -91,6 +91,7 @@ long base64_decode_block(const char* code_in, const int length_in, char* plainte
/** UEFI interface to base54 decode.
* Decodes EncodedData into a new allocated buffer and returns it. Caller is responsible to FreePool() it.
* If DecodedSize != NULL, then size od decoded data is put there.
* If return value is not NULL, DecodedSize IS > 0
*/
UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize)
{
@ -112,6 +113,11 @@ UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize)
base64_init_decodestate(&state_in);
DecodedSizeInternal = base64_decode_block(EncodedData, (const int)EncodedSize, (char*) DecodedData, &state_in);
if ( DecodedSizeInternal == 0 ) {
FreePool(DecodedData);
DecodedData = NULL;
}
if (DecodedSize != NULL) {
if ( DecodedSizeInternal < 0 ) panic("Base64DecodeClover : DecodedSizeInternal < 0");
*DecodedSize = (UINTN)DecodedSizeInternal;