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

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

