pack_json_state_fuzzer.c:flb_free:
  126|  1.48k|static inline void flb_free(void *ptr) {
  127|  1.48k|    free(ptr);
  128|  1.48k|}
flb_pack.c:flb_realloc:
  100|    836|{
  101|    836|    return realloc(ptr, size);
  102|    836|}
flb_pack.c:flb_malloc:
   67|  4.03k|void *flb_malloc(const size_t size) {
   68|       |
   69|  4.03k|#ifdef FLB_HAVE_TESTS_OSSFUZZ
   70|       |   // 1% chance of failure
   71|  4.03k|   if (flb_fuzz_get_probability(1)) {
  ------------------
  |  Branch (71:8): [True: 0, False: 4.03k]
  ------------------
   72|      0|     return NULL;
   73|      0|   }
   74|  4.03k|#endif
   75|       |
   76|  4.03k|    if (size == 0) {
  ------------------
  |  Branch (76:9): [True: 0, False: 4.03k]
  ------------------
   77|      0|        return NULL;
   78|      0|    }
   79|       |
   80|  4.03k|    return malloc(size);
   81|  4.03k|}
flb_pack.c:flb_fuzz_get_probability:
   56|  4.03k|static inline int flb_fuzz_get_probability(int val) {
   57|  4.03k|  flb_malloc_p += 1;
   58|  4.03k|  flb_malloc_p = flb_malloc_p % flb_malloc_mod;
   59|  4.03k|  if (val > flb_malloc_p) {
  ------------------
  |  Branch (59:7): [True: 0, False: 4.03k]
  ------------------
   60|      0|    return 1;
   61|      0|  }
   62|  4.03k|  return 0;
   63|  4.03k|}
flb_pack.c:flb_free:
  126|  4.03k|static inline void flb_free(void *ptr) {
  127|  4.03k|    free(ptr);
  128|  4.03k|}

jsmn_parse:
  269|  2.85k|                        jsmntok_t *tokens, const unsigned int num_tokens) {
  270|  2.85k|  int r;
  271|  2.85k|  int i;
  272|  2.85k|  jsmntok_t *token;
  273|  2.85k|  int count = parser->toknext;
  274|       |
  275|   420k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (275:10): [True: 418k, False: 1.58k]
  |  Branch (275:31): [True: 418k, False: 3]
  ------------------
  276|   418k|    char c;
  277|   418k|    jsmntype_t type;
  278|       |
  279|   418k|    c = js[parser->pos];
  280|   418k|    switch (c) {
  281|  12.2k|    case '{':
  ------------------
  |  Branch (281:5): [True: 12.2k, False: 406k]
  ------------------
  282|   131k|    case '[':
  ------------------
  |  Branch (282:5): [True: 119k, False: 299k]
  ------------------
  283|   131k|      count++;
  284|   131k|      if (tokens == NULL) {
  ------------------
  |  Branch (284:11): [True: 0, False: 131k]
  ------------------
  285|      0|        break;
  286|      0|      }
  287|   131k|      token = jsmn_alloc_token(parser, tokens, num_tokens);
  288|   131k|      if (token == NULL) {
  ------------------
  |  Branch (288:11): [True: 324, False: 131k]
  ------------------
  289|    324|        return JSMN_ERROR_NOMEM;
  290|    324|      }
  291|   131k|      if (parser->toksuper != -1) {
  ------------------
  |  Branch (291:11): [True: 129k, False: 1.37k]
  ------------------
  292|   129k|        jsmntok_t *t = &tokens[parser->toksuper];
  293|   129k|#ifdef JSMN_STRICT
  294|       |        /* In strict mode an object or array can't become a key */
  295|   129k|        if (t->type == JSMN_OBJECT) {
  ------------------
  |  Branch (295:13): [True: 13, False: 129k]
  ------------------
  296|     13|          return JSMN_ERROR_INVAL;
  297|     13|        }
  298|   129k|#endif
  299|   129k|        t->size++;
  300|   129k|#ifdef JSMN_PARENT_LINKS
  301|   129k|        token->parent = parser->toksuper;
  302|   129k|#endif
  303|   129k|      }
  304|   131k|      token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
  ------------------
  |  Branch (304:22): [True: 12.2k, False: 119k]
  ------------------
  305|   131k|      token->start = parser->pos;
  306|   131k|      parser->toksuper = parser->toknext - 1;
  307|   131k|      break;
  308|  12.7k|    case '}':
  ------------------
  |  Branch (308:5): [True: 12.7k, False: 405k]
  ------------------
  309|  24.8k|    case ']':
  ------------------
  |  Branch (309:5): [True: 12.1k, False: 406k]
  ------------------
  310|  24.8k|      if (tokens == NULL) {
  ------------------
  |  Branch (310:11): [True: 0, False: 24.8k]
  ------------------
  311|      0|        break;
  312|      0|      }
  313|  24.8k|      type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
  ------------------
  |  Branch (313:15): [True: 12.7k, False: 12.1k]
  ------------------
  314|  24.8k|#ifdef JSMN_PARENT_LINKS
  315|  24.8k|      if (parser->toknext < 1) {
  ------------------
  |  Branch (315:11): [True: 2, False: 24.8k]
  ------------------
  316|      2|        return JSMN_ERROR_INVAL;
  317|      2|      }
  318|  24.8k|      token = &tokens[parser->toknext - 1];
  319|  44.6k|      for (;;) {
  320|  44.6k|        if (token->start != -1 && token->end == -1) {
  ------------------
  |  Branch (320:13): [True: 44.6k, False: 0]
  |  Branch (320:35): [True: 23.8k, False: 20.8k]
  ------------------
  321|  23.8k|          if (token->type != type) {
  ------------------
  |  Branch (321:15): [True: 4, False: 23.8k]
  ------------------
  322|      4|            return JSMN_ERROR_INVAL;
  323|      4|          }
  324|  23.8k|          token->end = parser->pos + 1;
  325|  23.8k|          parser->toksuper = token->parent;
  326|  23.8k|          break;
  327|  23.8k|        }
  328|  20.8k|        if (token->parent == -1) {
  ------------------
  |  Branch (328:13): [True: 1.04k, False: 19.8k]
  ------------------
  329|  1.04k|          if (token->type != type || parser->toksuper == -1) {
  ------------------
  |  Branch (329:15): [True: 8, False: 1.03k]
  |  Branch (329:38): [True: 8, False: 1.03k]
  ------------------
  330|     16|            return JSMN_ERROR_INVAL;
  331|     16|          }
  332|  1.03k|          break;
  333|  1.04k|        }
  334|  19.8k|        token = &tokens[token->parent];
  335|  19.8k|      }
  336|       |#else
  337|       |      for (i = parser->toknext - 1; i >= 0; i--) {
  338|       |        token = &tokens[i];
  339|       |        if (token->start != -1 && token->end == -1) {
  340|       |          if (token->type != type) {
  341|       |            return JSMN_ERROR_INVAL;
  342|       |          }
  343|       |          parser->toksuper = -1;
  344|       |          token->end = parser->pos + 1;
  345|       |          break;
  346|       |        }
  347|       |      }
  348|       |      /* Error if unmatched closing bracket */
  349|       |      if (i == -1) {
  350|       |        return JSMN_ERROR_INVAL;
  351|       |      }
  352|       |      for (; i >= 0; i--) {
  353|       |        token = &tokens[i];
  354|       |        if (token->start != -1 && token->end == -1) {
  355|       |          parser->toksuper = i;
  356|       |          break;
  357|       |        }
  358|       |      }
  359|       |#endif
  360|  24.8k|      break;
  361|  24.8k|    case '\"':
  ------------------
  |  Branch (361:5): [True: 17.7k, False: 400k]
  ------------------
  362|  17.7k|      r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
  363|  17.7k|      if (r < 0) {
  ------------------
  |  Branch (363:11): [True: 303, False: 17.4k]
  ------------------
  364|    303|        return r;
  365|    303|      }
  366|  17.4k|      count++;
  367|  17.4k|      if (parser->toksuper != -1 && tokens != NULL) {
  ------------------
  |  Branch (367:11): [True: 15.7k, False: 1.72k]
  |  Branch (367:37): [True: 15.7k, False: 0]
  ------------------
  368|  15.7k|        tokens[parser->toksuper].size++;
  369|  15.7k|      }
  370|  17.4k|      break;
  371|  2.42k|    case '\t':
  ------------------
  |  Branch (371:5): [True: 2.42k, False: 416k]
  ------------------
  372|  4.27k|    case '\r':
  ------------------
  |  Branch (372:5): [True: 1.85k, False: 416k]
  ------------------
  373|  5.29k|    case '\n':
  ------------------
  |  Branch (373:5): [True: 1.02k, False: 417k]
  ------------------
  374|   113k|    case ' ':
  ------------------
  |  Branch (374:5): [True: 107k, False: 310k]
  ------------------
  375|   113k|      break;
  376|    614|    case ':':
  ------------------
  |  Branch (376:5): [True: 614, False: 417k]
  ------------------
  377|    614|      parser->toksuper = parser->toknext - 1;
  378|    614|      break;
  379|  4.38k|    case ',':
  ------------------
  |  Branch (379:5): [True: 4.38k, False: 414k]
  ------------------
  380|  4.38k|      if (tokens != NULL && parser->toksuper != -1 &&
  ------------------
  |  Branch (380:11): [True: 4.38k, False: 0]
  |  Branch (380:29): [True: 1.34k, False: 3.04k]
  ------------------
  381|  4.38k|          tokens[parser->toksuper].type != JSMN_ARRAY &&
  ------------------
  |  Branch (381:11): [True: 661, False: 684]
  ------------------
  382|  4.38k|          tokens[parser->toksuper].type != JSMN_OBJECT) {
  ------------------
  |  Branch (382:11): [True: 466, False: 195]
  ------------------
  383|    466|#ifdef JSMN_PARENT_LINKS
  384|    466|        parser->toksuper = tokens[parser->toksuper].parent;
  385|       |#else
  386|       |        for (i = parser->toknext - 1; i >= 0; i--) {
  387|       |          if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
  388|       |            if (tokens[i].start != -1 && tokens[i].end == -1) {
  389|       |              parser->toksuper = i;
  390|       |              break;
  391|       |            }
  392|       |          }
  393|       |        }
  394|       |#endif
  395|    466|      }
  396|  4.38k|      break;
  397|      0|#ifdef JSMN_STRICT
  398|       |    /* In strict mode primitives are: numbers and booleans */
  399|  1.69k|    case '-':
  ------------------
  |  Branch (399:5): [True: 1.69k, False: 416k]
  ------------------
  400|  12.5k|    case '0':
  ------------------
  |  Branch (400:5): [True: 10.8k, False: 407k]
  ------------------
  401|   105k|    case '1':
  ------------------
  |  Branch (401:5): [True: 92.9k, False: 325k]
  ------------------
  402|   111k|    case '2':
  ------------------
  |  Branch (402:5): [True: 5.76k, False: 412k]
  ------------------
  403|   111k|    case '3':
  ------------------
  |  Branch (403:5): [True: 646, False: 417k]
  ------------------
  404|   112k|    case '4':
  ------------------
  |  Branch (404:5): [True: 1.00k, False: 417k]
  ------------------
  405|   113k|    case '5':
  ------------------
  |  Branch (405:5): [True: 513, False: 418k]
  ------------------
  406|   113k|    case '6':
  ------------------
  |  Branch (406:5): [True: 484, False: 418k]
  ------------------
  407|   114k|    case '7':
  ------------------
  |  Branch (407:5): [True: 842, False: 417k]
  ------------------
  408|   115k|    case '8':
  ------------------
  |  Branch (408:5): [True: 704, False: 417k]
  ------------------
  409|   122k|    case '9':
  ------------------
  |  Branch (409:5): [True: 7.28k, False: 411k]
  ------------------
  410|   123k|    case 't':
  ------------------
  |  Branch (410:5): [True: 784, False: 417k]
  ------------------
  411|   124k|    case 'f':
  ------------------
  |  Branch (411:5): [True: 1.45k, False: 417k]
  ------------------
  412|   125k|    case 'n':
  ------------------
  |  Branch (412:5): [True: 1.00k, False: 417k]
  ------------------
  413|       |      /* And they must not be keys of the object */
  414|   125k|      if (tokens != NULL && parser->toksuper != -1) {
  ------------------
  |  Branch (414:11): [True: 125k, False: 0]
  |  Branch (414:29): [True: 20.2k, False: 105k]
  ------------------
  415|  20.2k|        const jsmntok_t *t = &tokens[parser->toksuper];
  416|  20.2k|        if (t->type == JSMN_OBJECT ||
  ------------------
  |  Branch (416:13): [True: 1, False: 20.2k]
  ------------------
  417|  20.2k|            (t->type == JSMN_STRING && t->size != 0)) {
  ------------------
  |  Branch (417:14): [True: 322, False: 19.9k]
  |  Branch (417:40): [True: 10, False: 312]
  ------------------
  418|     11|          return JSMN_ERROR_INVAL;
  419|     11|        }
  420|  20.2k|      }
  421|       |#else
  422|       |    /* In non-strict mode every unquoted value is a primitive */
  423|       |    default:
  424|       |#endif
  425|   125k|      r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
  426|   125k|      if (r < 0) {
  ------------------
  |  Branch (426:11): [True: 585, False: 125k]
  ------------------
  427|    585|        return r;
  428|    585|      }
  429|   125k|      count++;
  430|   125k|      if (parser->toksuper != -1 && tokens != NULL) {
  ------------------
  |  Branch (430:11): [True: 20.0k, False: 105k]
  |  Branch (430:37): [True: 20.0k, False: 0]
  ------------------
  431|  20.0k|        tokens[parser->toksuper].size++;
  432|  20.0k|      }
  433|   125k|      break;
  434|       |
  435|      0|#ifdef JSMN_STRICT
  436|       |    /* Unexpected char in strict mode */
  437|      5|    default:
  ------------------
  |  Branch (437:5): [True: 5, False: 418k]
  ------------------
  438|      5|      return JSMN_ERROR_INVAL;
  439|   418k|#endif
  440|   418k|    }
  441|   418k|  }
  442|       |
  443|  1.59k|  if (tokens != NULL) {
  ------------------
  |  Branch (443:7): [True: 1.59k, False: 0]
  ------------------
  444|   156k|    for (i = parser->toknext - 1; i >= 0; i--) {
  ------------------
  |  Branch (444:35): [True: 154k, False: 1.41k]
  ------------------
  445|       |      /* Unmatched opened object or array */
  446|   154k|      if (tokens[i].start != -1 && tokens[i].end == -1) {
  ------------------
  |  Branch (446:11): [True: 154k, False: 0]
  |  Branch (446:36): [True: 177, False: 154k]
  ------------------
  447|    177|        return JSMN_ERROR_PART;
  448|    177|      }
  449|   154k|    }
  450|  1.59k|  }
  451|       |
  452|  1.41k|  return count;
  453|  1.59k|}
jsmn_init:
  459|  2.01k|JSMN_API void jsmn_init(jsmn_parser *parser) {
  460|  2.01k|  parser->pos = 0;
  461|  2.01k|  parser->toknext = 0;
  462|  2.01k|  parser->toksuper = -1;
  463|  2.01k|}
jsmn.c:jsmn_alloc_token:
  107|   274k|                                   const size_t num_tokens) {
  108|   274k|  jsmntok_t *tok;
  109|   274k|  if (parser->toknext >= num_tokens) {
  ------------------
  |  Branch (109:7): [True: 836, False: 274k]
  ------------------
  110|    836|    return NULL;
  111|    836|  }
  112|   274k|  tok = &tokens[parser->toknext++];
  113|   274k|  tok->start = tok->end = -1;
  114|   274k|  tok->size = 0;
  115|   274k|#ifdef JSMN_PARENT_LINKS
  116|   274k|  tok->parent = -1;
  117|   274k|#endif
  118|   274k|  return tok;
  119|   274k|}
jsmn.c:jsmn_parse_string:
  195|  17.7k|                             const size_t num_tokens) {
  196|  17.7k|  jsmntok_t *token;
  197|       |
  198|  17.7k|  int start = parser->pos;
  199|       |
  200|  17.7k|  parser->pos++;
  201|       |
  202|       |  /* Skip starting quote */
  203|   103k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (203:10): [True: 103k, False: 170]
  |  Branch (203:31): [True: 103k, False: 4]
  ------------------
  204|   103k|    char c = js[parser->pos];
  205|       |
  206|       |    /* Quote: end of string */
  207|   103k|    if (c == '\"') {
  ------------------
  |  Branch (207:9): [True: 17.5k, False: 85.5k]
  ------------------
  208|  17.5k|      if (tokens == NULL) {
  ------------------
  |  Branch (208:11): [True: 0, False: 17.5k]
  ------------------
  209|      0|        return 0;
  210|      0|      }
  211|  17.5k|      token = jsmn_alloc_token(parser, tokens, num_tokens);
  212|  17.5k|      if (token == NULL) {
  ------------------
  |  Branch (212:11): [True: 97, False: 17.4k]
  ------------------
  213|     97|        parser->pos = start;
  214|     97|        return JSMN_ERROR_NOMEM;
  215|     97|      }
  216|  17.4k|      jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
  217|  17.4k|#ifdef JSMN_PARENT_LINKS
  218|  17.4k|      token->parent = parser->toksuper;
  219|  17.4k|#endif
  220|  17.4k|      return 0;
  221|  17.5k|    }
  222|       |
  223|       |    /* Backslash: Quoted symbol expected */
  224|  85.5k|    if (c == '\\' && parser->pos + 1 < len) {
  ------------------
  |  Branch (224:9): [True: 8.02k, False: 77.5k]
  |  Branch (224:22): [True: 8.02k, False: 5]
  ------------------
  225|  8.02k|      int i;
  226|  8.02k|      parser->pos++;
  227|  8.02k|      switch (js[parser->pos]) {
  228|       |      /* Allowed escaped symbols */
  229|    400|      case '\"':
  ------------------
  |  Branch (229:7): [True: 400, False: 7.62k]
  ------------------
  230|    851|      case '/':
  ------------------
  |  Branch (230:7): [True: 451, False: 7.57k]
  ------------------
  231|  1.27k|      case '\\':
  ------------------
  |  Branch (231:7): [True: 423, False: 7.59k]
  ------------------
  232|  1.70k|      case 'b':
  ------------------
  |  Branch (232:7): [True: 435, False: 7.58k]
  ------------------
  233|  2.26k|      case 'f':
  ------------------
  |  Branch (233:7): [True: 556, False: 7.46k]
  ------------------
  234|  2.81k|      case 'r':
  ------------------
  |  Branch (234:7): [True: 554, False: 7.46k]
  ------------------
  235|  3.42k|      case 'n':
  ------------------
  |  Branch (235:7): [True: 609, False: 7.41k]
  ------------------
  236|  4.18k|      case 't':
  ------------------
  |  Branch (236:7): [True: 756, False: 7.26k]
  ------------------
  237|  4.18k|        break;
  238|       |      /* Allows escaped symbol \uXXXX */
  239|  3.83k|      case 'u':
  ------------------
  |  Branch (239:7): [True: 3.83k, False: 4.18k]
  ------------------
  240|  3.83k|        parser->pos++;
  241|  18.9k|        for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0';
  ------------------
  |  Branch (241:21): [True: 15.1k, False: 3.76k]
  |  Branch (241:30): [True: 15.1k, False: 37]
  |  Branch (241:51): [True: 15.1k, False: 3]
  ------------------
  242|  15.1k|             i++) {
  243|       |          /* If it isn't a hex character we have an error */
  244|  15.1k|          if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) ||   /* 0-9 */
  ------------------
  |  Branch (244:18): [True: 15.1k, False: 14]
  |  Branch (244:43): [True: 7.83k, False: 7.29k]
  ------------------
  245|  15.1k|                (js[parser->pos] >= 65 && js[parser->pos] <= 70) ||   /* A-F */
  ------------------
  |  Branch (245:18): [True: 7.28k, False: 18]
  |  Branch (245:43): [True: 3.85k, False: 3.43k]
  ------------------
  246|  15.1k|                (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
  ------------------
  |  Branch (246:18): [True: 3.42k, False: 24]
  |  Branch (246:43): [True: 3.42k, False: 7]
  ------------------
  247|     31|            parser->pos = start;
  248|     31|            return JSMN_ERROR_INVAL;
  249|     31|          }
  250|  15.1k|          parser->pos++;
  251|  15.1k|        }
  252|  3.80k|        parser->pos--;
  253|  3.80k|        break;
  254|       |      /* Unexpected symbol */
  255|      1|      default:
  ------------------
  |  Branch (255:7): [True: 1, False: 8.02k]
  ------------------
  256|      1|        parser->pos = start;
  257|      1|        return JSMN_ERROR_INVAL;
  258|  8.02k|      }
  259|  8.02k|    }
  260|  85.5k|  }
  261|    174|  parser->pos = start;
  262|    174|  return JSMN_ERROR_PART;
  263|  17.7k|}
jsmn.c:jsmn_fill_token:
  125|   142k|                            const int start, const int end) {
  126|   142k|  token->type = type;
  127|   142k|  token->start = start;
  128|   142k|  token->end = end;
  129|   142k|  token->size = 0;
  130|   142k|}
jsmn.c:jsmn_parse_primitive:
  137|   125k|                                const size_t num_tokens) {
  138|   125k|  jsmntok_t *token;
  139|   125k|  int start;
  140|       |
  141|   125k|  start = parser->pos;
  142|       |
  143|   382k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (143:10): [True: 382k, False: 161]
  |  Branch (143:31): [True: 382k, False: 1]
  ------------------
  144|   382k|    switch (js[parser->pos]) {
  145|       |#ifndef JSMN_STRICT
  146|       |    /* In strict mode primitive must be followed by "," or "}" or "]" */
  147|       |    case ':':
  148|       |#endif
  149|  2.21k|    case '\t':
  ------------------
  |  Branch (149:5): [True: 2.21k, False: 380k]
  ------------------
  150|  3.88k|    case '\r':
  ------------------
  |  Branch (150:5): [True: 1.66k, False: 381k]
  ------------------
  151|  4.71k|    case '\n':
  ------------------
  |  Branch (151:5): [True: 828, False: 381k]
  ------------------
  152|   112k|    case ' ':
  ------------------
  |  Branch (152:5): [True: 107k, False: 274k]
  ------------------
  153|   116k|    case ',':
  ------------------
  |  Branch (153:5): [True: 3.57k, False: 379k]
  ------------------
  154|   125k|    case ']':
  ------------------
  |  Branch (154:5): [True: 9.42k, False: 373k]
  ------------------
  155|   125k|    case '}':
  ------------------
  |  Branch (155:5): [True: 196, False: 382k]
  ------------------
  156|   125k|      goto found;
  157|   257k|    default:
  ------------------
  |  Branch (157:5): [True: 257k, False: 125k]
  ------------------
  158|       |                   /* to quiet a warning from gcc*/
  159|   257k|      break;
  160|   382k|    }
  161|   257k|    if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
  ------------------
  |  Branch (161:9): [True: 7, False: 257k]
  |  Branch (161:33): [True: 1, False: 257k]
  ------------------
  162|      8|      parser->pos = start;
  163|      8|      return JSMN_ERROR_INVAL;
  164|      8|    }
  165|   257k|  }
  166|    162|#ifdef JSMN_STRICT
  167|       |  /* In strict mode primitive must be followed by a comma/object/array */
  168|    162|  parser->pos = start;
  169|    162|  return JSMN_ERROR_PART;
  170|      0|#endif
  171|       |
  172|   125k|found:
  173|   125k|  if (tokens == NULL) {
  ------------------
  |  Branch (173:7): [True: 0, False: 125k]
  ------------------
  174|      0|    parser->pos--;
  175|      0|    return 0;
  176|      0|  }
  177|   125k|  token = jsmn_alloc_token(parser, tokens, num_tokens);
  178|   125k|  if (token == NULL) {
  ------------------
  |  Branch (178:7): [True: 415, False: 125k]
  ------------------
  179|    415|    parser->pos = start;
  180|    415|    return JSMN_ERROR_NOMEM;
  181|    415|  }
  182|   125k|  jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
  183|   125k|#ifdef JSMN_PARENT_LINKS
  184|   125k|  token->parent = parser->toksuper;
  185|   125k|#endif
  186|   125k|  parser->pos--;
  187|   125k|  return 0;
  188|   125k|}

flb_pack.c:msgpack_packer_init:
  131|  1.48k|{
  132|  1.48k|    pk->data = data;
  133|  1.48k|    pk->callback = callback;
  134|  1.48k|}

flb_pack.c:msgpack_pack_false:
  710|  1.01k|{
  711|  1.01k|    static const unsigned char d = 0xc2;
  712|  1.01k|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|  1.01k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  713|  1.01k|}
flb_pack.c:msgpack_pack_true:
  704|    707|{
  705|    707|    static const unsigned char d = 0xc3;
  706|    707|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|    707|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  707|    707|}
flb_pack.c:msgpack_pack_nil:
  693|    957|{
  694|    957|    static const unsigned char d = 0xc0;
  695|    957|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|    957|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  696|    957|}
flb_pack.c:msgpack_pack_int64:
  376|  14.3k|{
  377|  14.3k|    msgpack_pack_real_int64(x, d);
  ------------------
  |  |  221|  14.3k|#define msgpack_pack_real_int64(x, d) \
  |  |  222|  14.3k|do { \
  |  |  223|  14.3k|    if(d < -(1LL<<5)) { \
  |  |  ------------------
  |  |  |  Branch (223:8): [True: 1.02k, False: 13.3k]
  |  |  ------------------
  |  |  224|  1.02k|        if(d < -(1LL<<15)) { \
  |  |  ------------------
  |  |  |  Branch (224:12): [True: 590, False: 431]
  |  |  ------------------
  |  |  225|    590|            if(d < -(1LL<<31)) { \
  |  |  ------------------
  |  |  |  Branch (225:16): [True: 319, False: 271]
  |  |  ------------------
  |  |  226|    319|                /* signed 64 */ \
  |  |  227|    319|                unsigned char buf[9]; \
  |  |  228|    319|                buf[0] = 0xd3; _msgpack_store64(&buf[1], d); \
  |  |  ------------------
  |  |  |  |  186|    319|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    319|#        define _msgpack_be64(x) bswap_64(x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  229|    319|                msgpack_pack_append_buffer(x, buf, 9); \
  |  |  ------------------
  |  |  |  |  126|    319|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  230|    319|            } else { \
  |  |  231|    271|                /* signed 32 */ \
  |  |  232|    271|                unsigned char buf[5]; \
  |  |  233|    271|                buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
  |  |  ------------------
  |  |  |  |  184|    271|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  124|    271|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  234|    271|                msgpack_pack_append_buffer(x, buf, 5); \
  |  |  ------------------
  |  |  |  |  126|    271|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  235|    271|            } \
  |  |  236|    590|        } else { \
  |  |  237|    431|            if(d < -(1<<7)) { \
  |  |  ------------------
  |  |  |  Branch (237:16): [True: 228, False: 203]
  |  |  ------------------
  |  |  238|    228|                /* signed 16 */ \
  |  |  239|    228|                unsigned char buf[3]; \
  |  |  240|    228|                buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
  |  |  ------------------
  |  |  |  |  182|    228|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    228|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  241|    228|                msgpack_pack_append_buffer(x, buf, 3); \
  |  |  ------------------
  |  |  |  |  126|    228|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  242|    228|            } else { \
  |  |  243|    203|                /* signed 8 */ \
  |  |  244|    203|                unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \
  |  |  ------------------
  |  |  |  |   22|    203|#define TAKE8_64(d) ((uint8_t*)&d)[0]
  |  |  ------------------
  |  |  245|    203|                msgpack_pack_append_buffer(x, buf, 2); \
  |  |  ------------------
  |  |  |  |  126|    203|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  246|    203|            } \
  |  |  247|    431|        } \
  |  |  248|  13.3k|    } else if(d < (1<<7)) { \
  |  |  ------------------
  |  |  |  Branch (248:15): [True: 12.2k, False: 1.12k]
  |  |  ------------------
  |  |  249|  12.2k|        /* fixnum */ \
  |  |  250|  12.2k|        msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
  |  |  ------------------
  |  |  |  |  126|  12.2k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  251|  12.2k|    } else { \
  |  |  252|  1.12k|        if(d < (1LL<<16)) { \
  |  |  ------------------
  |  |  |  Branch (252:12): [True: 475, False: 647]
  |  |  ------------------
  |  |  253|    475|            if(d < (1<<8)) { \
  |  |  ------------------
  |  |  |  Branch (253:16): [True: 203, False: 272]
  |  |  ------------------
  |  |  254|    203|                /* unsigned 8 */ \
  |  |  255|    203|                unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
  |  |  ------------------
  |  |  |  |   22|    203|#define TAKE8_64(d) ((uint8_t*)&d)[0]
  |  |  ------------------
  |  |  256|    203|                msgpack_pack_append_buffer(x, buf, 2); \
  |  |  ------------------
  |  |  |  |  126|    203|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  257|    272|            } else { \
  |  |  258|    272|                /* unsigned 16 */ \
  |  |  259|    272|                unsigned char buf[3]; \
  |  |  260|    272|                buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
  |  |  ------------------
  |  |  |  |  182|    272|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    272|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  261|    272|                msgpack_pack_append_buffer(x, buf, 3); \
  |  |  ------------------
  |  |  |  |  126|    272|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  262|    272|            } \
  |  |  263|    647|        } else { \
  |  |  264|    647|            if(d < (1LL<<32)) { \
  |  |  ------------------
  |  |  |  Branch (264:16): [True: 302, False: 345]
  |  |  ------------------
  |  |  265|    302|                /* unsigned 32 */ \
  |  |  266|    302|                unsigned char buf[5]; \
  |  |  267|    302|                buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
  |  |  ------------------
  |  |  |  |  184|    302|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  124|    302|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  268|    302|                msgpack_pack_append_buffer(x, buf, 5); \
  |  |  ------------------
  |  |  |  |  126|    302|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  269|    345|            } else { \
  |  |  270|    345|                /* unsigned 64 */ \
  |  |  271|    345|                unsigned char buf[9]; \
  |  |  272|    345|                buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
  |  |  ------------------
  |  |  |  |  186|    345|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    345|#        define _msgpack_be64(x) bswap_64(x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  273|    345|                msgpack_pack_append_buffer(x, buf, 9); \
  |  |  ------------------
  |  |  |  |  126|    345|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  274|    345|            } \
  |  |  275|    647|        } \
  |  |  276|  1.12k|    } \
  |  |  277|  14.3k|} while(0)
  |  |  ------------------
  |  |  |  Branch (277:9): [Folded - Ignored]
  |  |  ------------------
  ------------------
  378|  14.3k|}
flb_pack.c:msgpack_pack_array:
  721|  11.1k|{
  722|  11.1k|    if(n < 16) {
  ------------------
  |  Branch (722:8): [True: 10.6k, False: 500]
  ------------------
  723|  10.6k|        unsigned char d = 0x90 | (uint8_t)n;
  724|  10.6k|        msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|  10.6k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  725|  10.6k|    } else if(n < 65536) {
  ------------------
  |  Branch (725:15): [True: 500, False: 0]
  ------------------
  726|    500|        unsigned char buf[3];
  727|    500|        buf[0] = 0xdc; _msgpack_store16(&buf[1], (uint16_t)n);
  ------------------
  |  |  182|    500|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|    500|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  728|    500|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|    500|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  729|    500|    } else {
  730|      0|        unsigned char buf[5];
  731|      0|        buf[0] = 0xdd; _msgpack_store32(&buf[1], (uint32_t)n);
  ------------------
  |  |  184|      0|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  ------------------
  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  732|      0|        msgpack_pack_append_buffer(x, buf, 5);
  ------------------
  |  |  126|      0|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  733|      0|    }
  734|  11.1k|}
flb_pack.c:msgpack_pack_map:
  742|  11.4k|{
  743|  11.4k|    if(n < 16) {
  ------------------
  |  Branch (743:8): [True: 11.3k, False: 105]
  ------------------
  744|  11.3k|        unsigned char d = 0x80 | (uint8_t)n;
  745|  11.3k|        msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
  ------------------
  |  |  126|  11.3k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  746|  11.3k|    } else if(n < 65536) {
  ------------------
  |  Branch (746:15): [True: 105, False: 0]
  ------------------
  747|    105|        unsigned char buf[3];
  748|    105|        buf[0] = 0xde; _msgpack_store16(&buf[1], (uint16_t)n);
  ------------------
  |  |  182|    105|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|    105|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  749|    105|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|    105|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  750|    105|    } else {
  751|      0|        unsigned char buf[5];
  752|      0|        buf[0] = 0xdf; _msgpack_store32(&buf[1], (uint32_t)n);
  ------------------
  |  |  184|      0|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  ------------------
  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  753|      0|        msgpack_pack_append_buffer(x, buf, 5);
  ------------------
  |  |  126|      0|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  754|      0|    }
  755|  11.4k|}
flb_pack.c:msgpack_pack_str:
  763|  13.3k|{
  764|  13.3k|    if(l < 32) {
  ------------------
  |  Branch (764:8): [True: 13.1k, False: 229]
  ------------------
  765|  13.1k|        unsigned char d = 0xa0 | (uint8_t)l;
  766|  13.1k|        msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
  ------------------
  |  |  126|  13.1k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  767|  13.1k|    } else if(l < 256) {
  ------------------
  |  Branch (767:15): [True: 155, False: 74]
  ------------------
  768|    155|        unsigned char buf[2];
  769|    155|        buf[0] = 0xd9; buf[1] = (uint8_t)l;
  770|    155|        msgpack_pack_append_buffer(x, buf, 2);
  ------------------
  |  |  126|    155|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  771|    155|    } else if(l < 65536) {
  ------------------
  |  Branch (771:15): [True: 74, False: 0]
  ------------------
  772|     74|        unsigned char buf[3];
  773|     74|        buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
  ------------------
  |  |  182|     74|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|     74|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  774|     74|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|     74|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  775|     74|    } else {
  776|      0|        unsigned char buf[5];
  777|      0|        buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
  ------------------
  |  |  184|      0|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  ------------------
  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  778|      0|        msgpack_pack_append_buffer(x, buf, 5);
  ------------------
  |  |  126|      0|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  779|      0|    }
  780|  13.3k|}
flb_pack.c:msgpack_pack_str_body:
  783|  13.3k|{
  784|  13.3k|    msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
  ------------------
  |  |  126|  13.3k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  785|  13.3k|}
flb_pack.c:msgpack_pack_double:
  672|   104k|{
  673|   104k|    unsigned char buf[9];
  674|   104k|    union { double f; uint64_t i; } mem;
  675|   104k|    mem.f = d;
  676|   104k|    buf[0] = 0xcb;
  677|       |#if defined(TARGET_OS_IPHONE)
  678|       |    // ok
  679|       |#elif defined(__arm__) && !(__ARM_EABI__) // arm-oabi
  680|       |    // https://github.com/msgpack/msgpack-perl/pull/1
  681|       |    mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
  682|       |#endif
  683|   104k|    _msgpack_store64(&buf[1], mem.i);
  ------------------
  |  |  186|   104k|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  ------------------
  |  |  |  |  142|   104k|#        define _msgpack_be64(x) bswap_64(x)
  |  |  ------------------
  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  684|   104k|    msgpack_pack_append_buffer(x, buf, 9);
  ------------------
  |  |  126|   104k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  685|   104k|}

flb_pack.c:msgpack_sbuffer_init:
   35|  1.48k|{
   36|  1.48k|    memset(sbuf, 0, sizeof(msgpack_sbuffer));
   37|  1.48k|}
flb_pack.c:msgpack_sbuffer_write:
   61|   171k|{
   62|   171k|    msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
   63|       |
   64|   171k|    assert(buf || len == 0);
   65|   171k|    if(!buf) return 0;
  ------------------
  |  Branch (65:8): [True: 0, False: 171k]
  ------------------
   66|       |
   67|   171k|    if(sbuf->alloc - sbuf->size < len) {
  ------------------
  |  Branch (67:8): [True: 1.51k, False: 169k]
  ------------------
   68|  1.51k|        void* tmp;
   69|  1.51k|        size_t nsize = (sbuf->alloc) ?
  ------------------
  |  Branch (69:24): [True: 31, False: 1.48k]
  ------------------
   70|  1.48k|                sbuf->alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE;
  ------------------
  |  |   57|  1.48k|#define MSGPACK_SBUFFER_INIT_SIZE 8192
  ------------------
   71|       |
   72|  1.51k|        while(nsize < sbuf->size + len) {
  ------------------
  |  Branch (72:15): [True: 0, False: 1.51k]
  ------------------
   73|      0|            size_t tmp_nsize = nsize * 2;
   74|      0|            if (tmp_nsize <= nsize) {
  ------------------
  |  Branch (74:17): [True: 0, False: 0]
  ------------------
   75|      0|                nsize = sbuf->size + len;
   76|      0|                break;
   77|      0|            }
   78|      0|            nsize = tmp_nsize;
   79|      0|        }
   80|       |
   81|  1.51k|        tmp = realloc(sbuf->data, nsize);
   82|  1.51k|        if(!tmp) { return -1; }
  ------------------
  |  Branch (82:12): [True: 0, False: 1.51k]
  ------------------
   83|       |
   84|  1.51k|        sbuf->data = (char*)tmp;
   85|  1.51k|        sbuf->alloc = nsize;
   86|  1.51k|    }
   87|       |
   88|   171k|    memcpy(sbuf->data + sbuf->size, buf, len);
   89|   171k|    sbuf->size += len;
   90|       |
   91|   171k|    return 0;
   92|   171k|}

flb_json_tokenise:
   55|  2.01k|{
   56|  2.01k|    int ret;
   57|  2.01k|    int new_tokens = 256;
   58|  2.01k|    size_t old_size;
   59|  2.01k|    size_t new_size;
   60|  2.01k|    void *tmp;
   61|       |
   62|  2.01k|    ret = jsmn_parse(&state->parser, js, len,
   63|  2.01k|                     state->tokens, state->tokens_size);
   64|  2.85k|    while (ret == JSMN_ERROR_NOMEM) {
  ------------------
  |  Branch (64:12): [True: 836, False: 2.01k]
  ------------------
   65|       |        /* Get current size of the array in bytes */
   66|    836|        old_size = state->tokens_size * sizeof(jsmntok_t);
   67|       |
   68|       |        /* New size: add capacity for new 256 entries */
   69|    836|        new_size = old_size + (sizeof(jsmntok_t) * new_tokens);
   70|       |
   71|    836|        tmp = flb_realloc(state->tokens, new_size);
   72|    836|        if (!tmp) {
  ------------------
  |  Branch (72:13): [True: 0, False: 836]
  ------------------
   73|      0|            flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
   74|      0|            return -1;
   75|      0|        }
   76|    836|        state->tokens = tmp;
   77|    836|        state->tokens_size += new_tokens;
   78|       |
   79|    836|        ret = jsmn_parse(&state->parser, js, len,
   80|    836|                         state->tokens, state->tokens_size);
   81|    836|    }
   82|       |
   83|  2.01k|    if (ret == JSMN_ERROR_INVAL) {
  ------------------
  |  Branch (83:9): [True: 91, False: 1.92k]
  ------------------
   84|     91|        return FLB_ERR_JSON_INVAL;
  ------------------
  |  |   45|     91|#define FLB_ERR_JSON_INVAL           -501
  ------------------
   85|     91|    }
   86|       |
   87|  1.92k|    if (ret == JSMN_ERROR_PART) {
  ------------------
  |  Branch (87:9): [True: 513, False: 1.41k]
  ------------------
   88|       |        /* This is a partial JSON message, just stop */
   89|    513|        flb_trace("[json tokenise] incomplete");
  ------------------
  |  |  193|    513|#define flb_trace(fmt, ...)  do {} while(0)
  |  |  ------------------
  |  |  |  Branch (193:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
   90|    513|        return FLB_ERR_JSON_PART;
  ------------------
  |  |   46|    513|#define FLB_ERR_JSON_PART            -502
  ------------------
   91|    513|    }
   92|       |
   93|  1.41k|    state->tokens_count += ret;
   94|  1.41k|    return 0;
   95|  1.92k|}
flb_pack_state_init:
  304|  2.01k|{
  305|  2.01k|    int tokens = 256;
  306|  2.01k|    size_t size = 256;
  307|       |
  308|  2.01k|    jsmn_init(&s->parser);
  309|       |
  310|  2.01k|    size = sizeof(jsmntok_t) * tokens;
  311|  2.01k|    s->tokens = flb_malloc(size);
  312|  2.01k|    if (!s->tokens) {
  ------------------
  |  Branch (312:9): [True: 0, False: 2.01k]
  ------------------
  313|      0|        flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
  314|      0|        return -1;
  315|      0|    }
  316|  2.01k|    s->tokens_size   = tokens;
  317|  2.01k|    s->tokens_count  = 0;
  318|  2.01k|    s->last_byte     = 0;
  319|  2.01k|    s->multiple      = FLB_FALSE;
  ------------------
  |  |   25|  2.01k|#define FLB_FALSE  0
  ------------------
  320|       |
  321|  2.01k|    s->buf_data = flb_malloc(size);
  322|  2.01k|    if (!s->buf_data) {
  ------------------
  |  Branch (322:9): [True: 0, False: 2.01k]
  ------------------
  323|      0|        flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
  324|      0|        flb_free(s->tokens);
  325|      0|        s->tokens = NULL;
  326|      0|        return -1;
  327|      0|    }
  328|  2.01k|    s->buf_size = size;
  329|  2.01k|    s->buf_len = 0;
  330|       |
  331|  2.01k|    return 0;
  332|  2.01k|}
flb_pack_state_reset:
  335|  2.01k|{
  336|  2.01k|    flb_free(s->tokens);
  337|  2.01k|    s->tokens = NULL;
  338|  2.01k|    s->tokens_size  = 0;
  339|  2.01k|    s->tokens_count = 0;
  340|  2.01k|    s->last_byte    = 0;
  341|  2.01k|    s->buf_size     = 0;
  342|  2.01k|    flb_free(s->buf_data);
  343|  2.01k|    s->buf_data = NULL;
  344|  2.01k|}
flb_pack_json_state:
  356|  2.01k|{
  357|  2.01k|    int ret;
  358|  2.01k|    int out;
  359|  2.01k|    int delim = 0;
  360|  2.01k|    int last =  0;
  361|  2.01k|    int records;
  362|  2.01k|    char *buf;
  363|  2.01k|    jsmntok_t *t;
  364|       |
  365|  2.01k|    ret = flb_json_tokenise(js, len, state);
  366|  2.01k|    state->multiple = FLB_TRUE;
  ------------------
  |  |   26|  2.01k|#define FLB_TRUE   !FLB_FALSE
  |  |  ------------------
  |  |  |  |   25|  2.01k|#define FLB_FALSE  0
  |  |  ------------------
  ------------------
  367|  2.01k|    if (ret == FLB_ERR_JSON_PART && state->multiple == FLB_TRUE) {
  ------------------
  |  |   46|  4.03k|#define FLB_ERR_JSON_PART            -502
  ------------------
                  if (ret == FLB_ERR_JSON_PART && state->multiple == FLB_TRUE) {
  ------------------
  |  |   26|    513|#define FLB_TRUE   !FLB_FALSE
  |  |  ------------------
  |  |  |  |   25|    513|#define FLB_FALSE  0
  |  |  ------------------
  ------------------
  |  Branch (367:9): [True: 513, False: 1.50k]
  |  Branch (367:37): [True: 513, False: 0]
  ------------------
  368|       |        /*
  369|       |         * If the caller enabled 'multiple' flag, it means that the incoming
  370|       |         * JSON message may have multiple messages concatenated and likely
  371|       |         * the last one is only incomplete.
  372|       |         *
  373|       |         * The following routine aims to determinate how many JSON messages
  374|       |         * are OK in the array of tokens, if any, process them and adjust
  375|       |         * the JSMN context/buffers.
  376|       |         */
  377|       |
  378|       |        /*
  379|       |         * jsmn_parse updates jsmn_parser members. (state->parser)
  380|       |         * A member 'toknext' points next incomplete object token.
  381|       |         * We use toknext - 1 as an index of last member of complete JSON.
  382|       |         */
  383|    513|        int i;
  384|    513|        int found = 0;
  385|       |
  386|    513|        if (state->parser.toknext == 0) {
  ------------------
  |  Branch (386:13): [True: 186, False: 327]
  ------------------
  387|    186|            return ret;
  388|    186|        }
  389|       |
  390|   104k|        for (i = (int)state->parser.toknext - 1; i >= 1; i--) {
  ------------------
  |  Branch (390:50): [True: 104k, False: 212]
  ------------------
  391|   104k|            t = &state->tokens[i];
  392|       |
  393|   104k|            if (t->parent == -1 && (t->end != 0)) {
  ------------------
  |  Branch (393:17): [True: 115, False: 104k]
  |  Branch (393:36): [True: 115, False: 0]
  ------------------
  394|    115|                found++;
  395|    115|                delim = i;
  396|    115|                break;
  397|    115|            }
  398|   104k|        }
  399|       |
  400|    327|        if (found == 0) {
  ------------------
  |  Branch (400:13): [True: 212, False: 115]
  ------------------
  401|    212|            return ret; /* FLB_ERR_JSON_PART */
  402|    212|        }
  403|    115|        state->tokens_count += delim;
  404|    115|    }
  405|  1.50k|    else if (ret != 0) {
  ------------------
  |  Branch (405:14): [True: 91, False: 1.41k]
  ------------------
  406|     91|        return ret;
  407|     91|    }
  408|       |
  409|  1.53k|    if (state->tokens_count == 0 || state->tokens == NULL) {
  ------------------
  |  Branch (409:9): [True: 49, False: 1.48k]
  |  Branch (409:37): [True: 0, False: 1.48k]
  ------------------
  410|     49|        state->last_byte = last;
  411|     49|        return FLB_ERR_JSON_INVAL;
  ------------------
  |  |   45|     49|#define FLB_ERR_JSON_INVAL           -501
  ------------------
  412|     49|    }
  413|       |
  414|  1.48k|    buf = tokens_to_msgpack(state, js, &out, &last, &records);
  415|  1.48k|    if (!buf) {
  ------------------
  |  Branch (415:9): [True: 0, False: 1.48k]
  ------------------
  416|      0|        return -1;
  417|      0|    }
  418|       |
  419|  1.48k|    *size = out;
  420|  1.48k|    *buffer = buf;
  421|  1.48k|    state->last_byte = last;
  422|       |
  423|  1.48k|    return 0;
  424|  1.48k|}
flb_pack.c:tokens_to_msgpack:
  154|  1.48k|{
  155|  1.48k|    int i;
  156|  1.48k|    int flen;
  157|  1.48k|    int arr_size;
  158|  1.48k|    int records = 0;
  159|  1.48k|    const char *p;
  160|  1.48k|    char *buf;
  161|  1.48k|    const jsmntok_t *t;
  162|  1.48k|    msgpack_packer pck;
  163|  1.48k|    msgpack_sbuffer sbuf;
  164|  1.48k|    jsmntok_t *tokens;
  165|       |
  166|  1.48k|    tokens = state->tokens;
  167|  1.48k|    arr_size = state->tokens_count;
  168|       |
  169|  1.48k|    if (arr_size == 0) {
  ------------------
  |  Branch (169:9): [True: 0, False: 1.48k]
  ------------------
  170|      0|        return NULL;
  171|      0|    }
  172|       |
  173|       |    /* initialize buffers */
  174|  1.48k|    msgpack_sbuffer_init(&sbuf);
  175|  1.48k|    msgpack_packer_init(&pck, &sbuf, msgpack_sbuffer_write);
  176|       |
  177|   159k|    for (i = 0; i < arr_size ; i++) {
  ------------------
  |  Branch (177:17): [True: 157k, False: 1.48k]
  ------------------
  178|   157k|        t = &tokens[i];
  179|       |
  180|   157k|        if (t->start == -1 || t->end == -1 || (t->start == 0 && t->end == 0)) {
  ------------------
  |  Branch (180:13): [True: 0, False: 157k]
  |  Branch (180:31): [True: 0, False: 157k]
  |  Branch (180:48): [True: 1.11k, False: 156k]
  |  Branch (180:65): [True: 0, False: 1.11k]
  ------------------
  181|      0|            break;
  182|      0|        }
  183|       |
  184|   157k|        if (t->parent == -1) {
  ------------------
  |  Branch (184:13): [True: 106k, False: 51.8k]
  ------------------
  185|   106k|            *last_byte = t->end;
  186|   106k|            records++;
  187|   106k|        }
  188|       |
  189|   157k|        flen = (t->end - t->start);
  190|   157k|        switch (t->type) {
  ------------------
  |  Branch (190:17): [True: 0, False: 157k]
  ------------------
  191|  11.4k|        case JSMN_OBJECT:
  ------------------
  |  Branch (191:9): [True: 11.4k, False: 146k]
  ------------------
  192|  11.4k|            msgpack_pack_map(&pck, t->size);
  193|  11.4k|            break;
  194|  11.1k|        case JSMN_ARRAY:
  ------------------
  |  Branch (194:9): [True: 11.1k, False: 146k]
  ------------------
  195|  11.1k|            msgpack_pack_array(&pck, t->size);
  196|  11.1k|            break;
  197|  13.3k|        case JSMN_STRING:
  ------------------
  |  Branch (197:9): [True: 13.3k, False: 144k]
  ------------------
  198|  13.3k|            pack_string_token(state, js + t->start, flen, &pck);
  199|  13.3k|            break;
  200|   121k|        case JSMN_PRIMITIVE:
  ------------------
  |  Branch (200:9): [True: 121k, False: 36.0k]
  ------------------
  201|   121k|            p = js + t->start;
  202|   121k|            if (*p == 'f') {
  ------------------
  |  Branch (202:17): [True: 1.01k, False: 120k]
  ------------------
  203|  1.01k|                msgpack_pack_false(&pck);
  204|  1.01k|            }
  205|   120k|            else if (*p == 't') {
  ------------------
  |  Branch (205:22): [True: 707, False: 120k]
  ------------------
  206|    707|                msgpack_pack_true(&pck);
  207|    707|            }
  208|   120k|            else if (*p == 'n') {
  ------------------
  |  Branch (208:22): [True: 957, False: 119k]
  ------------------
  209|    957|                msgpack_pack_nil(&pck);
  210|    957|            }
  211|   119k|            else {
  212|   119k|                if (is_float(p, flen)) {
  ------------------
  |  Branch (212:21): [True: 104k, False: 14.3k]
  ------------------
  213|   104k|                    msgpack_pack_double(&pck, atof(p));
  214|   104k|                }
  215|  14.3k|                else {
  216|  14.3k|                    msgpack_pack_int64(&pck, atoll(p));
  217|  14.3k|                }
  218|   119k|            }
  219|   121k|            break;
  220|      0|        case JSMN_UNDEFINED:
  ------------------
  |  Branch (220:9): [True: 0, False: 157k]
  ------------------
  221|      0|            msgpack_sbuffer_destroy(&sbuf);
  222|      0|            return NULL;
  223|   157k|        }
  224|   157k|    }
  225|       |
  226|  1.48k|    *out_size = sbuf.size;
  227|  1.48k|    *out_records = records;
  228|  1.48k|    buf = sbuf.data;
  229|       |
  230|  1.48k|    return buf;
  231|  1.48k|}
flb_pack.c:pack_string_token:
  119|  13.3k|{
  120|  13.3k|    int s;
  121|  13.3k|    int out_len;
  122|  13.3k|    char *tmp;
  123|  13.3k|    char *out_buf;
  124|       |
  125|  13.3k|    if (state->buf_size < len + 1) {
  ------------------
  |  Branch (125:9): [True: 0, False: 13.3k]
  ------------------
  126|      0|        s = len + 1;
  127|      0|        tmp = flb_realloc(state->buf_data, s);
  128|      0|        if (!tmp) {
  ------------------
  |  Branch (128:13): [True: 0, False: 0]
  ------------------
  129|      0|            flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
  130|      0|            return -1;
  131|      0|        }
  132|      0|        else {
  133|      0|            state->buf_data = tmp;
  134|      0|            state->buf_size = s;
  135|      0|        }
  136|      0|    }
  137|  13.3k|    out_buf = state->buf_data;
  138|       |
  139|       |    /* Always decode any UTF-8 or special characters */
  140|  13.3k|    out_len = flb_unescape_string_utf8(str, len, out_buf);
  141|       |
  142|       |    /* Pack decoded text */
  143|  13.3k|    msgpack_pack_str(pck, out_len);
  144|  13.3k|    msgpack_pack_str_body(pck, out_buf, out_len);
  145|       |
  146|  13.3k|    return out_len;
  147|  13.3k|}
flb_pack.c:is_float:
   98|   119k|{
   99|   119k|    const char *end = buf + len;
  100|   119k|    const char *p = buf;
  101|       |
  102|   274k|    while (p <= end) {
  ------------------
  |  Branch (102:12): [True: 259k, False: 14.3k]
  ------------------
  103|   259k|        if (*p == 'e' && p < end && *(p + 1) == '-') {
  ------------------
  |  Branch (103:13): [True: 561, False: 259k]
  |  Branch (103:26): [True: 561, False: 0]
  |  Branch (103:37): [True: 194, False: 367]
  ------------------
  104|    194|            return 1;
  105|    194|        }
  106|   259k|        else if (*p == '.') {
  ------------------
  |  Branch (106:18): [True: 104k, False: 154k]
  ------------------
  107|   104k|            return 1;
  108|   104k|        }
  109|   154k|        p++;
  110|   154k|    }
  111|       |
  112|  14.3k|    return 0;
  113|   119k|}

flb_unescape_string_utf8:
  128|  13.3k|{
  129|  13.3k|    uint32_t ch;
  130|  13.3k|    char temp[4];
  131|  13.3k|    const char *end;
  132|  13.3k|    const char *next;
  133|  13.3k|                int size;
  134|       |
  135|       |
  136|  13.3k|    int count_out = 0;
  137|  13.3k|    int count_in = 0;
  138|  13.3k|    int esc_in = 0;
  139|  13.3k|    int esc_out = 0;
  140|       |
  141|  13.3k|    end = in_buf + sz;
  142|  82.3k|    while (in_buf < end && *in_buf && count_in < sz) {
  ------------------
  |  Branch (142:12): [True: 68.9k, False: 13.3k]
  |  Branch (142:28): [True: 68.9k, False: 0]
  |  Branch (142:39): [True: 68.9k, False: 0]
  ------------------
  143|  68.9k|        next = in_buf + 1;
  144|  68.9k|        if (next < end && *in_buf == '\\') {
  ------------------
  |  Branch (144:13): [True: 68.4k, False: 539]
  |  Branch (144:27): [True: 4.68k, False: 63.7k]
  ------------------
  145|  4.68k|            esc_in = 2;
  146|  4.68k|            switch (*next) {
  147|    206|            case '"':
  ------------------
  |  Branch (147:13): [True: 206, False: 4.47k]
  ------------------
  148|    206|                ch = '"';
  149|    206|                break;
  150|      0|            case '\'':
  ------------------
  |  Branch (150:13): [True: 0, False: 4.68k]
  ------------------
  151|      0|                ch = '\'';
  152|      0|                break;
  153|    225|            case '\\':
  ------------------
  |  Branch (153:13): [True: 225, False: 4.46k]
  ------------------
  154|    225|                ch = '\\';
  155|    225|                break;
  156|    194|            case '/':
  ------------------
  |  Branch (156:13): [True: 194, False: 4.49k]
  ------------------
  157|    194|                ch = '/';
  158|    194|                break;
  159|    284|            case 'n':
  ------------------
  |  Branch (159:13): [True: 284, False: 4.40k]
  ------------------
  160|    284|                ch = '\n';
  161|    284|                break;
  162|    227|            case 'b':
  ------------------
  |  Branch (162:13): [True: 227, False: 4.45k]
  ------------------
  163|    227|                ch = '\b';
  164|    227|                break;
  165|    365|            case 't':
  ------------------
  |  Branch (165:13): [True: 365, False: 4.32k]
  ------------------
  166|    365|                ch = '\t';
  167|    365|                break;
  168|    335|            case 'f':
  ------------------
  |  Branch (168:13): [True: 335, False: 4.35k]
  ------------------
  169|    335|                ch = '\f';
  170|    335|                break;
  171|    233|            case 'r':
  ------------------
  |  Branch (171:13): [True: 233, False: 4.45k]
  ------------------
  172|    233|                ch = '\r';
  173|    233|                break;
  174|  2.61k|            default:
  ------------------
  |  Branch (174:13): [True: 2.61k, False: 2.06k]
  ------------------
  175|  2.61k|                size = end - next;
  176|  2.61k|                if (size > 0) {
  ------------------
  |  Branch (176:21): [True: 2.61k, False: 0]
  ------------------
  177|  2.61k|                    esc_in = u8_read_escape_sequence(next, size, &ch) + 1;
  178|  2.61k|                }
  179|      0|                else {
  180|       |                    /* because char is unsigned char by default on arm, so we need to do a explicit conversion */
  181|      0|                    ch = (uint32_t) (signed char) *in_buf;
  182|      0|                    esc_in = 1;
  183|      0|                }
  184|  4.68k|            }
  185|  4.68k|        }
  186|  64.2k|        else {
  187|       |            /* explicit convert char to signed char */
  188|  64.2k|            ch = (uint32_t) (signed char) *in_buf;
  189|  64.2k|            esc_in = 1;
  190|  64.2k|        }
  191|       |
  192|  68.9k|        in_buf += esc_in;
  193|  68.9k|        count_in += esc_in;
  194|       |
  195|  68.9k|        esc_out = u8_wc_toutf8(temp, ch);
  196|  68.9k|        if (esc_out > sz-count_out) {
  ------------------
  |  Branch (196:13): [True: 0, False: 68.9k]
  ------------------
  197|      0|            flb_error("Crossing over string boundary");
  ------------------
  |  |  140|      0|    if (flb_log_check(FLB_LOG_ERROR))                                \
  |  |  ------------------
  |  |  |  |   39|      0|#define FLB_LOG_ERROR   1
  |  |  ------------------
  |  |  |  Branch (140:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  141|      0|        flb_log_print(FLB_LOG_ERROR, NULL, 0, fmt, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   39|      0|#define FLB_LOG_ERROR   1
  |  |  ------------------
  ------------------
  198|      0|            break;
  199|      0|        }
  200|       |
  201|  68.9k|        if (esc_out == 0) {
  ------------------
  |  Branch (201:13): [True: 14.6k, False: 54.3k]
  ------------------
  202|  14.6k|            out_buf[count_out] = ch;
  203|  14.6k|            esc_out = 1;
  204|  14.6k|        }
  205|  54.3k|        else if (esc_out == 1) {
  ------------------
  |  Branch (205:18): [True: 51.7k, False: 2.61k]
  ------------------
  206|  51.7k|            out_buf[count_out] = (char) temp[0];
  207|  51.7k|        }
  208|  2.61k|        else {
  209|  2.61k|            memcpy(&out_buf[count_out], temp, esc_out);
  210|  2.61k|        }
  211|  68.9k|        count_out += esc_out;
  212|  68.9k|    }
  213|  13.3k|    if (count_in < sz) {
  ------------------
  |  Branch (213:9): [True: 0, False: 13.3k]
  ------------------
  214|      0|        flb_error("Not at boundary but still NULL terminating : %d - '%s'", sz, in_buf);
  ------------------
  |  |  140|      0|    if (flb_log_check(FLB_LOG_ERROR))                                \
  |  |  ------------------
  |  |  |  |   39|      0|#define FLB_LOG_ERROR   1
  |  |  ------------------
  |  |  |  Branch (140:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  141|      0|        flb_log_print(FLB_LOG_ERROR, NULL, 0, fmt, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   39|      0|#define FLB_LOG_ERROR   1
  |  |  ------------------
  ------------------
  215|      0|    }
  216|  13.3k|    out_buf[count_out] = '\0';
  217|  13.3k|    return count_out;
  218|  13.3k|}
flb_unescape.c:u8_read_escape_sequence:
   70|  2.61k|{
   71|  2.61k|    uint32_t ch;
   72|  2.61k|    char digs[9]="\0\0\0\0\0\0\0\0";
   73|  2.61k|    int dno=0, i=1;
   74|       |
   75|  2.61k|    ch = (uint32_t)str[0];    /* take literal character */
   76|       |
   77|  2.61k|    if (str[0] == 'n')
  ------------------
  |  Branch (77:9): [True: 0, False: 2.61k]
  ------------------
   78|      0|        ch = L'\n';
   79|  2.61k|    else if (str[0] == 't')
  ------------------
  |  Branch (79:14): [True: 0, False: 2.61k]
  ------------------
   80|      0|        ch = L'\t';
   81|  2.61k|    else if (str[0] == 'r')
  ------------------
  |  Branch (81:14): [True: 0, False: 2.61k]
  ------------------
   82|      0|        ch = L'\r';
   83|  2.61k|    else if (str[0] == 'b')
  ------------------
  |  Branch (83:14): [True: 0, False: 2.61k]
  ------------------
   84|      0|        ch = L'\b';
   85|  2.61k|    else if (str[0] == 'f')
  ------------------
  |  Branch (85:14): [True: 0, False: 2.61k]
  ------------------
   86|      0|        ch = L'\f';
   87|  2.61k|    else if (str[0] == 'v')
  ------------------
  |  Branch (87:14): [True: 0, False: 2.61k]
  ------------------
   88|      0|        ch = L'\v';
   89|  2.61k|    else if (str[0] == 'a')
  ------------------
  |  Branch (89:14): [True: 0, False: 2.61k]
  ------------------
   90|      0|        ch = L'\a';
   91|  2.61k|    else if (octal_digit(str[0])) {
  ------------------
  |  Branch (91:14): [True: 0, False: 2.61k]
  ------------------
   92|      0|        i = 0;
   93|      0|        do {
   94|      0|            digs[dno++] = str[i++];
   95|      0|        } while (i < size && octal_digit(str[i]) && dno < 3);
  ------------------
  |  Branch (95:18): [True: 0, False: 0]
  |  Branch (95:30): [True: 0, False: 0]
  |  Branch (95:53): [True: 0, False: 0]
  ------------------
   96|      0|        ch = strtol(digs, NULL, 8);
   97|      0|    }
   98|  2.61k|    else if (str[0] == 'x') {
  ------------------
  |  Branch (98:14): [True: 0, False: 2.61k]
  ------------------
   99|      0|        while (i < size && hex_digit(str[i]) && dno < 2) {
  ------------------
  |  Branch (99:16): [True: 0, False: 0]
  |  Branch (99:28): [True: 0, False: 0]
  |  Branch (99:49): [True: 0, False: 0]
  ------------------
  100|      0|            digs[dno++] = str[i++];
  101|      0|        }
  102|      0|        if (dno > 0) {
  ------------------
  |  Branch (102:13): [True: 0, False: 0]
  ------------------
  103|      0|            ch = strtol(digs, NULL, 16);
  104|      0|        }
  105|      0|    }
  106|  2.61k|    else if (str[0] == 'u') {
  ------------------
  |  Branch (106:14): [True: 2.61k, False: 0]
  ------------------
  107|  13.0k|        while (i < size && hex_digit(str[i]) && dno < 4) {
  ------------------
  |  Branch (107:16): [True: 12.7k, False: 296]
  |  Branch (107:28): [True: 10.8k, False: 1.90k]
  |  Branch (107:49): [True: 10.4k, False: 412]
  ------------------
  108|  10.4k|            digs[dno++] = str[i++];
  109|  10.4k|        }
  110|  2.61k|        if (dno > 0) {
  ------------------
  |  Branch (110:13): [True: 2.61k, False: 0]
  ------------------
  111|  2.61k|            ch = strtol(digs, NULL, 16);
  112|  2.61k|        }
  113|  2.61k|    }
  114|      0|    else if (str[0] == 'U') {
  ------------------
  |  Branch (114:14): [True: 0, False: 0]
  ------------------
  115|      0|        while (i < size && hex_digit(str[i]) && dno < 8) {
  ------------------
  |  Branch (115:16): [True: 0, False: 0]
  |  Branch (115:28): [True: 0, False: 0]
  |  Branch (115:49): [True: 0, False: 0]
  ------------------
  116|      0|            digs[dno++] = str[i++];
  117|      0|        }
  118|      0|        if (dno > 0) {
  ------------------
  |  Branch (118:13): [True: 0, False: 0]
  ------------------
  119|      0|            ch = strtol(digs, NULL, 16);
  120|      0|        }
  121|      0|    }
  122|  2.61k|    *dest = ch;
  123|       |
  124|  2.61k|    return i;
  125|  2.61k|}
flb_unescape.c:octal_digit:
   29|  2.61k|{
   30|  2.61k|    return (c >= '0' && c <= '7');
  ------------------
  |  Branch (30:13): [True: 2.61k, False: 0]
  |  Branch (30:25): [True: 0, False: 2.61k]
  ------------------
   31|  2.61k|}
flb_unescape.c:hex_digit:
   34|  12.7k|{
   35|  12.7k|    return ((c >= '0' && c <= '9') ||
  ------------------
  |  Branch (35:14): [True: 12.2k, False: 562]
  |  Branch (35:26): [True: 6.37k, False: 5.85k]
  ------------------
   36|  12.7k|            (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (36:14): [True: 5.64k, False: 768]
  |  Branch (36:26): [True: 2.08k, False: 3.55k]
  ------------------
   37|  12.7k|            (c >= 'a' && c <= 'f'));
  ------------------
  |  Branch (37:14): [True: 2.49k, False: 1.83k]
  |  Branch (37:26): [True: 2.41k, False: 75]
  ------------------
   38|  12.7k|}
flb_unescape.c:u8_wc_toutf8:
   41|  68.9k|{
   42|  68.9k|    if (ch < 0x80) {
  ------------------
  |  Branch (42:9): [True: 51.7k, False: 17.2k]
  ------------------
   43|  51.7k|        dest[0] = (char)ch;
   44|  51.7k|        return 1;
   45|  51.7k|    }
   46|  17.2k|    if (ch < 0x800) {
  ------------------
  |  Branch (46:9): [True: 510, False: 16.7k]
  ------------------
   47|    510|        dest[0] = (ch>>6) | 0xC0;
   48|    510|        dest[1] = (ch & 0x3F) | 0x80;
   49|    510|        return 2;
   50|    510|    }
   51|  16.7k|    if (ch < 0x10000) {
  ------------------
  |  Branch (51:9): [True: 2.10k, False: 14.6k]
  ------------------
   52|  2.10k|        dest[0] = (ch>>12) | 0xE0;
   53|  2.10k|        dest[1] = ((ch>>6) & 0x3F) | 0x80;
   54|  2.10k|        dest[2] = (ch & 0x3F) | 0x80;
   55|  2.10k|        return 3;
   56|  2.10k|    }
   57|  14.6k|    if (ch < 0x110000) {
  ------------------
  |  Branch (57:9): [True: 0, False: 14.6k]
  ------------------
   58|      0|        dest[0] = (ch>>18) | 0xF0;
   59|      0|        dest[1] = ((ch>>12) & 0x3F) | 0x80;
   60|      0|        dest[2] = ((ch>>6) & 0x3F) | 0x80;
   61|      0|        dest[3] = (ch & 0x3F) | 0x80;
   62|      0|        return 4;
   63|      0|    }
   64|  14.6k|    return 0;
   65|  14.6k|}

LLVMFuzzerTestOneInput:
    5|  2.03k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){
    6|  2.03k|    int out_size= 0;
    7|  2.03k|    char *out_buf = NULL;
    8|  2.03k|    struct flb_pack_state state;
    9|       |    /* Set fuzzer-malloc chance of failure */
   10|  2.03k|    flb_malloc_mod = 25000;
   11|  2.03k|    flb_malloc_p = 0;
   12|       |
   13|       |    /* Exit early to avoid timeouts due to excessive size */
   14|  2.03k|    if (size > 4096)
  ------------------
  |  Branch (14:9): [True: 11, False: 2.01k]
  ------------------
   15|     11|        return 0;
   16|       |
   17|       |    /* Target json packer */
   18|  2.01k|    flb_pack_state_init(&state);
   19|  2.01k|    flb_pack_json_state(data, size, &out_buf, &out_size, &state);
   20|  2.01k|    flb_pack_state_reset(&state);
   21|  2.01k|    if (out_buf != NULL)
  ------------------
  |  Branch (21:9): [True: 1.48k, False: 538]
  ------------------
   22|  1.48k|        flb_free(out_buf);
   23|       |
   24|  2.01k|    return 0;
   25|  2.03k|}

