LLVMFuzzerTestOneInput:
   26|    116|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   27|       |    // Base64Decode expects a null-terminated string.
   28|    116|    char *str = (char *)malloc(size + 1);
   29|    116|    if (!str) {
  ------------------
  |  Branch (29:9): [True: 0, False: 116]
  ------------------
   30|      0|        return 0;
   31|      0|    }
   32|    116|    memcpy(str, data, size);
   33|    116|    str[size] = '\0';
   34|       |
   35|    116|    unsigned char *buffer = NULL;
   36|    116|    size_t length = 0;
   37|       |
   38|       |    // Call the target function
   39|    116|    Base64Decode(str, &buffer, &length);
   40|       |
   41|    116|    if (buffer) {
  ------------------
  |  Branch (41:9): [True: 116, False: 0]
  ------------------
   42|    116|        free(buffer);
   43|    116|    }
   44|    116|    free(str);
   45|    116|    return 0;
   46|    116|}

calcDecodeLength:
  131|    116|size_t calcDecodeLength(const char* b64input) { //Calculates the length of a decoded string
  132|    116|    size_t len = strlen(b64input), padding = 0;
  133|    116|    if (len >= 2 && b64input[len-1] == '=' && b64input[len-2] == '=') //last two chars are =
  ------------------
  |  Branch (133:9): [True: 101, False: 15]
  |  Branch (133:21): [True: 43, False: 58]
  |  Branch (133:47): [True: 27, False: 16]
  ------------------
  134|     27|        padding = 2;
  135|     89|    else if (len >= 1 && b64input[len-1] == '=') //last char is =
  ------------------
  |  Branch (135:14): [True: 88, False: 1]
  |  Branch (135:26): [True: 19, False: 69]
  ------------------
  136|     19|        padding = 1;
  137|       |
  138|    116|    size_t decoded_len = (len*3)/4;
  139|    116|    if (padding > decoded_len) {
  ------------------
  |  Branch (139:9): [True: 4, False: 112]
  ------------------
  140|      4|        return 0;
  141|      4|    }
  142|    112|    return decoded_len - padding;
  143|    116|}
Base64Decode:
  145|    116|int Base64Decode(const char* b64message, unsigned char** buffer, size_t* length) { //Decodes a base64 encoded string
  146|    116|    BIO *bio, *b64;
  147|    116|    int br;
  148|       |
  149|    116|    size_t decodeLen = calcDecodeLength(b64message);
  150|    116|    *buffer = (unsigned char*)malloc(decodeLen + 1);
  151|    116|    if (!*buffer)
  ------------------
  |  Branch (151:9): [True: 0, False: 116]
  ------------------
  152|      0|        return -1;
  153|    116|    (*buffer)[decodeLen] = '\0';
  154|    116|    *length = 0;
  155|       |
  156|    116|    bio = BIO_new_mem_buf(b64message, -1);
  157|    116|    b64 = BIO_new(BIO_f_base64());
  158|    116|    bio = BIO_push(b64, bio);
  159|       |
  160|    116|    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer
  161|    116|    br = BIO_read(bio, *buffer, strlen(b64message));
  162|    116|    BIO_free_all(bio);
  163|       |
  164|    116|    if (br < 0) {
  ------------------
  |  Branch (164:9): [True: 0, False: 116]
  ------------------
  165|      0|        free(*buffer);
  166|      0|        *buffer = NULL;
  167|      0|        return -1;
  168|      0|    }
  169|    116|    *length = (size_t)br;
  170|       |
  171|    116|    return (0); //success
  172|    116|}

