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

jsmn_parse:
  269|  2.84k|                        jsmntok_t *tokens, const unsigned int num_tokens) {
  270|  2.84k|  int r;
  271|  2.84k|  int i;
  272|  2.84k|  jsmntok_t *token;
  273|  2.84k|  int count = parser->toknext;
  274|       |
  275|   416k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (275:10): [True: 415k, False: 1.59k]
  |  Branch (275:31): [True: 415k, False: 1]
  ------------------
  276|   415k|    char c;
  277|   415k|    jsmntype_t type;
  278|       |
  279|   415k|    c = js[parser->pos];
  280|   415k|    switch (c) {
  281|  9.26k|    case '{':
  ------------------
  |  Branch (281:5): [True: 9.26k, False: 405k]
  ------------------
  282|   135k|    case '[':
  ------------------
  |  Branch (282:5): [True: 125k, False: 289k]
  ------------------
  283|   135k|      count++;
  284|   135k|      if (tokens == NULL) {
  ------------------
  |  Branch (284:11): [True: 0, False: 135k]
  ------------------
  285|      0|        break;
  286|      0|      }
  287|   135k|      token = jsmn_alloc_token(parser, tokens, num_tokens);
  288|   135k|      if (token == NULL) {
  ------------------
  |  Branch (288:11): [True: 344, False: 134k]
  ------------------
  289|    344|        return JSMN_ERROR_NOMEM;
  290|    344|      }
  291|   134k|      if (parser->toksuper != -1) {
  ------------------
  |  Branch (291:11): [True: 133k, False: 1.45k]
  ------------------
  292|   133k|        jsmntok_t *t = &tokens[parser->toksuper];
  293|   133k|#ifdef JSMN_STRICT
  294|       |        /* In strict mode an object or array can't become a key */
  295|   133k|        if (t->type == JSMN_OBJECT) {
  ------------------
  |  Branch (295:13): [True: 13, False: 133k]
  ------------------
  296|     13|          return JSMN_ERROR_INVAL;
  297|     13|        }
  298|   133k|#endif
  299|   133k|        t->size++;
  300|   133k|#ifdef JSMN_PARENT_LINKS
  301|   133k|        token->parent = parser->toksuper;
  302|   133k|#endif
  303|   133k|      }
  304|   134k|      token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
  ------------------
  |  Branch (304:22): [True: 9.22k, False: 125k]
  ------------------
  305|   134k|      token->start = parser->pos;
  306|   134k|      parser->toksuper = parser->toknext - 1;
  307|   134k|      break;
  308|  9.70k|    case '}':
  ------------------
  |  Branch (308:5): [True: 9.70k, False: 405k]
  ------------------
  309|  23.7k|    case ']':
  ------------------
  |  Branch (309:5): [True: 14.0k, False: 401k]
  ------------------
  310|  23.7k|      if (tokens == NULL) {
  ------------------
  |  Branch (310:11): [True: 0, False: 23.7k]
  ------------------
  311|      0|        break;
  312|      0|      }
  313|  23.7k|      type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
  ------------------
  |  Branch (313:15): [True: 9.70k, False: 14.0k]
  ------------------
  314|  23.7k|#ifdef JSMN_PARENT_LINKS
  315|  23.7k|      if (parser->toknext < 1) {
  ------------------
  |  Branch (315:11): [True: 2, False: 23.7k]
  ------------------
  316|      2|        return JSMN_ERROR_INVAL;
  317|      2|      }
  318|  23.7k|      token = &tokens[parser->toknext - 1];
  319|  75.2k|      for (;;) {
  320|  75.2k|        if (token->start != -1 && token->end == -1) {
  ------------------
  |  Branch (320:13): [True: 75.2k, False: 0]
  |  Branch (320:35): [True: 21.1k, False: 54.1k]
  ------------------
  321|  21.1k|          if (token->type != type) {
  ------------------
  |  Branch (321:15): [True: 5, False: 21.1k]
  ------------------
  322|      5|            return JSMN_ERROR_INVAL;
  323|      5|          }
  324|  21.1k|          token->end = parser->pos + 1;
  325|  21.1k|          parser->toksuper = token->parent;
  326|  21.1k|          break;
  327|  21.1k|        }
  328|  54.1k|        if (token->parent == -1) {
  ------------------
  |  Branch (328:13): [True: 2.62k, False: 51.4k]
  ------------------
  329|  2.62k|          if (token->type != type || parser->toksuper == -1) {
  ------------------
  |  Branch (329:15): [True: 7, False: 2.61k]
  |  Branch (329:38): [True: 5, False: 2.61k]
  ------------------
  330|     12|            return JSMN_ERROR_INVAL;
  331|     12|          }
  332|  2.61k|          break;
  333|  2.62k|        }
  334|  51.4k|        token = &tokens[token->parent];
  335|  51.4k|      }
  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|  23.7k|      break;
  361|  23.7k|    case '\"':
  ------------------
  |  Branch (361:5): [True: 15.8k, False: 399k]
  ------------------
  362|  15.8k|      r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
  363|  15.8k|      if (r < 0) {
  ------------------
  |  Branch (363:11): [True: 286, False: 15.5k]
  ------------------
  364|    286|        return r;
  365|    286|      }
  366|  15.5k|      count++;
  367|  15.5k|      if (parser->toksuper != -1 && tokens != NULL) {
  ------------------
  |  Branch (367:11): [True: 13.5k, False: 1.98k]
  |  Branch (367:37): [True: 13.5k, False: 0]
  ------------------
  368|  13.5k|        tokens[parser->toksuper].size++;
  369|  13.5k|      }
  370|  15.5k|      break;
  371|  2.25k|    case '\t':
  ------------------
  |  Branch (371:5): [True: 2.25k, False: 412k]
  ------------------
  372|  4.72k|    case '\r':
  ------------------
  |  Branch (372:5): [True: 2.47k, False: 412k]
  ------------------
  373|  6.00k|    case '\n':
  ------------------
  |  Branch (373:5): [True: 1.28k, False: 413k]
  ------------------
  374|   110k|    case ' ':
  ------------------
  |  Branch (374:5): [True: 104k, False: 310k]
  ------------------
  375|   110k|      break;
  376|    849|    case ':':
  ------------------
  |  Branch (376:5): [True: 849, False: 414k]
  ------------------
  377|    849|      parser->toksuper = parser->toknext - 1;
  378|    849|      break;
  379|  4.43k|    case ',':
  ------------------
  |  Branch (379:5): [True: 4.43k, False: 410k]
  ------------------
  380|  4.43k|      if (tokens != NULL && parser->toksuper != -1 &&
  ------------------
  |  Branch (380:11): [True: 4.43k, False: 0]
  |  Branch (380:29): [True: 1.53k, False: 2.90k]
  ------------------
  381|  4.43k|          tokens[parser->toksuper].type != JSMN_ARRAY &&
  ------------------
  |  Branch (381:11): [True: 608, False: 927]
  ------------------
  382|  4.43k|          tokens[parser->toksuper].type != JSMN_OBJECT) {
  ------------------
  |  Branch (382:11): [True: 414, False: 194]
  ------------------
  383|    414|#ifdef JSMN_PARENT_LINKS
  384|    414|        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|    414|      }
  396|  4.43k|      break;
  397|      0|#ifdef JSMN_STRICT
  398|       |    /* In strict mode primitives are: numbers and booleans */
  399|  2.14k|    case '-':
  ------------------
  |  Branch (399:5): [True: 2.14k, False: 413k]
  ------------------
  400|  13.5k|    case '0':
  ------------------
  |  Branch (400:5): [True: 11.4k, False: 403k]
  ------------------
  401|   104k|    case '1':
  ------------------
  |  Branch (401:5): [True: 90.9k, False: 324k]
  ------------------
  402|   110k|    case '2':
  ------------------
  |  Branch (402:5): [True: 5.92k, False: 409k]
  ------------------
  403|   111k|    case '3':
  ------------------
  |  Branch (403:5): [True: 625, False: 414k]
  ------------------
  404|   112k|    case '4':
  ------------------
  |  Branch (404:5): [True: 1.13k, False: 414k]
  ------------------
  405|   112k|    case '5':
  ------------------
  |  Branch (405:5): [True: 441, False: 414k]
  ------------------
  406|   113k|    case '6':
  ------------------
  |  Branch (406:5): [True: 657, False: 414k]
  ------------------
  407|   114k|    case '7':
  ------------------
  |  Branch (407:5): [True: 819, False: 414k]
  ------------------
  408|   114k|    case '8':
  ------------------
  |  Branch (408:5): [True: 822, False: 414k]
  ------------------
  409|   121k|    case '9':
  ------------------
  |  Branch (409:5): [True: 6.99k, False: 408k]
  ------------------
  410|   122k|    case 't':
  ------------------
  |  Branch (410:5): [True: 854, False: 414k]
  ------------------
  411|   123k|    case 'f':
  ------------------
  |  Branch (411:5): [True: 938, False: 414k]
  ------------------
  412|   124k|    case 'n':
  ------------------
  |  Branch (412:5): [True: 912, False: 414k]
  ------------------
  413|       |      /* And they must not be keys of the object */
  414|   124k|      if (tokens != NULL && parser->toksuper != -1) {
  ------------------
  |  Branch (414:11): [True: 124k, False: 0]
  |  Branch (414:29): [True: 21.7k, False: 102k]
  ------------------
  415|  21.7k|        const jsmntok_t *t = &tokens[parser->toksuper];
  416|  21.7k|        if (t->type == JSMN_OBJECT ||
  ------------------
  |  Branch (416:13): [True: 1, False: 21.7k]
  ------------------
  417|  21.7k|            (t->type == JSMN_STRING && t->size != 0)) {
  ------------------
  |  Branch (417:14): [True: 267, False: 21.4k]
  |  Branch (417:40): [True: 10, False: 257]
  ------------------
  418|     11|          return JSMN_ERROR_INVAL;
  419|     11|        }
  420|  21.7k|      }
  421|       |#else
  422|       |    /* In non-strict mode every unquoted value is a primitive */
  423|       |    default:
  424|       |#endif
  425|   124k|      r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
  426|   124k|      if (r < 0) {
  ------------------
  |  Branch (426:11): [True: 577, False: 124k]
  ------------------
  427|    577|        return r;
  428|    577|      }
  429|   124k|      count++;
  430|   124k|      if (parser->toksuper != -1 && tokens != NULL) {
  ------------------
  |  Branch (430:11): [True: 21.5k, False: 102k]
  |  Branch (430:37): [True: 21.5k, False: 0]
  ------------------
  431|  21.5k|        tokens[parser->toksuper].size++;
  432|  21.5k|      }
  433|   124k|      break;
  434|       |
  435|      0|#ifdef JSMN_STRICT
  436|       |    /* Unexpected char in strict mode */
  437|      5|    default:
  ------------------
  |  Branch (437:5): [True: 5, False: 415k]
  ------------------
  438|      5|      return JSMN_ERROR_INVAL;
  439|   415k|#endif
  440|   415k|    }
  441|   415k|  }
  442|       |
  443|  1.59k|  if (tokens != NULL) {
  ------------------
  |  Branch (443:7): [True: 1.59k, False: 0]
  ------------------
  444|   151k|    for (i = parser->toknext - 1; i >= 0; i--) {
  ------------------
  |  Branch (444:35): [True: 150k, False: 1.41k]
  ------------------
  445|       |      /* Unmatched opened object or array */
  446|   150k|      if (tokens[i].start != -1 && tokens[i].end == -1) {
  ------------------
  |  Branch (446:11): [True: 150k, False: 0]
  |  Branch (446:36): [True: 177, False: 150k]
  ------------------
  447|    177|        return JSMN_ERROR_PART;
  448|    177|      }
  449|   150k|    }
  450|  1.59k|  }
  451|       |
  452|  1.41k|  return count;
  453|  1.59k|}
jsmn_init:
  459|  2.00k|JSMN_API void jsmn_init(jsmn_parser *parser) {
  460|  2.00k|  parser->pos = 0;
  461|  2.00k|  parser->toknext = 0;
  462|  2.00k|  parser->toksuper = -1;
  463|  2.00k|}
jsmn.c:jsmn_alloc_token:
  107|   275k|                                   const size_t num_tokens) {
  108|   275k|  jsmntok_t *tok;
  109|   275k|  if (parser->toknext >= num_tokens) {
  ------------------
  |  Branch (109:7): [True: 838, False: 274k]
  ------------------
  110|    838|    return NULL;
  111|    838|  }
  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|   275k|}
jsmn.c:jsmn_parse_string:
  195|  15.8k|                             const size_t num_tokens) {
  196|  15.8k|  jsmntok_t *token;
  197|       |
  198|  15.8k|  int start = parser->pos;
  199|       |
  200|  15.8k|  parser->pos++;
  201|       |
  202|       |  /* Skip starting quote */
  203|   112k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (203:10): [True: 112k, False: 165]
  |  Branch (203:31): [True: 112k, False: 3]
  ------------------
  204|   112k|    char c = js[parser->pos];
  205|       |
  206|       |    /* Quote: end of string */
  207|   112k|    if (c == '\"') {
  ------------------
  |  Branch (207:9): [True: 15.6k, False: 96.5k]
  ------------------
  208|  15.6k|      if (tokens == NULL) {
  ------------------
  |  Branch (208:11): [True: 0, False: 15.6k]
  ------------------
  209|      0|        return 0;
  210|      0|      }
  211|  15.6k|      token = jsmn_alloc_token(parser, tokens, num_tokens);
  212|  15.6k|      if (token == NULL) {
  ------------------
  |  Branch (212:11): [True: 86, False: 15.5k]
  ------------------
  213|     86|        parser->pos = start;
  214|     86|        return JSMN_ERROR_NOMEM;
  215|     86|      }
  216|  15.5k|      jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
  217|  15.5k|#ifdef JSMN_PARENT_LINKS
  218|  15.5k|      token->parent = parser->toksuper;
  219|  15.5k|#endif
  220|  15.5k|      return 0;
  221|  15.6k|    }
  222|       |
  223|       |    /* Backslash: Quoted symbol expected */
  224|  96.5k|    if (c == '\\' && parser->pos + 1 < len) {
  ------------------
  |  Branch (224:9): [True: 6.59k, False: 89.9k]
  |  Branch (224:22): [True: 6.59k, False: 2]
  ------------------
  225|  6.59k|      int i;
  226|  6.59k|      parser->pos++;
  227|  6.59k|      switch (js[parser->pos]) {
  228|       |      /* Allowed escaped symbols */
  229|    438|      case '\"':
  ------------------
  |  Branch (229:7): [True: 438, False: 6.15k]
  ------------------
  230|  1.11k|      case '/':
  ------------------
  |  Branch (230:7): [True: 672, False: 5.91k]
  ------------------
  231|  1.59k|      case '\\':
  ------------------
  |  Branch (231:7): [True: 482, False: 6.10k]
  ------------------
  232|  2.06k|      case 'b':
  ------------------
  |  Branch (232:7): [True: 475, False: 6.11k]
  ------------------
  233|  2.48k|      case 'f':
  ------------------
  |  Branch (233:7): [True: 414, False: 6.17k]
  ------------------
  234|  2.93k|      case 'r':
  ------------------
  |  Branch (234:7): [True: 451, False: 6.14k]
  ------------------
  235|  3.36k|      case 'n':
  ------------------
  |  Branch (235:7): [True: 431, False: 6.16k]
  ------------------
  236|  3.87k|      case 't':
  ------------------
  |  Branch (236:7): [True: 513, False: 6.07k]
  ------------------
  237|  3.87k|        break;
  238|       |      /* Allows escaped symbol \uXXXX */
  239|  2.71k|      case 'u':
  ------------------
  |  Branch (239:7): [True: 2.71k, False: 3.87k]
  ------------------
  240|  2.71k|        parser->pos++;
  241|  13.3k|        for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0';
  ------------------
  |  Branch (241:21): [True: 10.6k, False: 2.64k]
  |  Branch (241:30): [True: 10.6k, False: 37]
  |  Branch (241:51): [True: 10.6k, False: 1]
  ------------------
  242|  10.6k|             i++) {
  243|       |          /* If it isn't a hex character we have an error */
  244|  10.6k|          if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) ||   /* 0-9 */
  ------------------
  |  Branch (244:18): [True: 10.6k, False: 14]
  |  Branch (244:43): [True: 4.82k, False: 5.82k]
  ------------------
  245|  10.6k|                (js[parser->pos] >= 65 && js[parser->pos] <= 70) ||   /* A-F */
  ------------------
  |  Branch (245:18): [True: 5.81k, False: 18]
  |  Branch (245:43): [True: 3.22k, False: 2.59k]
  ------------------
  246|  10.6k|                (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
  ------------------
  |  Branch (246:18): [True: 2.58k, False: 24]
  |  Branch (246:43): [True: 2.58k, False: 5]
  ------------------
  247|     29|            parser->pos = start;
  248|     29|            return JSMN_ERROR_INVAL;
  249|     29|          }
  250|  10.6k|          parser->pos++;
  251|  10.6k|        }
  252|  2.68k|        parser->pos--;
  253|  2.68k|        break;
  254|       |      /* Unexpected symbol */
  255|      3|      default:
  ------------------
  |  Branch (255:7): [True: 3, False: 6.58k]
  ------------------
  256|      3|        parser->pos = start;
  257|      3|        return JSMN_ERROR_INVAL;
  258|  6.59k|      }
  259|  6.59k|    }
  260|  96.5k|  }
  261|    168|  parser->pos = start;
  262|    168|  return JSMN_ERROR_PART;
  263|  15.8k|}
jsmn.c:jsmn_fill_token:
  125|   139k|                            const int start, const int end) {
  126|   139k|  token->type = type;
  127|   139k|  token->start = start;
  128|   139k|  token->end = end;
  129|   139k|  token->size = 0;
  130|   139k|}
jsmn.c:jsmn_parse_primitive:
  137|   124k|                                const size_t num_tokens) {
  138|   124k|  jsmntok_t *token;
  139|   124k|  int start;
  140|       |
  141|   124k|  start = parser->pos;
  142|       |
  143|   381k|  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
  ------------------
  |  Branch (143:10): [True: 381k, False: 159]
  |  Branch (143:31): [True: 381k, False: 1]
  ------------------
  144|   381k|    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.05k|    case '\t':
  ------------------
  |  Branch (149:5): [True: 2.05k, False: 379k]
  ------------------
  150|  4.17k|    case '\r':
  ------------------
  |  Branch (150:5): [True: 2.12k, False: 379k]
  ------------------
  151|  5.26k|    case '\n':
  ------------------
  |  Branch (151:5): [True: 1.08k, False: 380k]
  ------------------
  152|   109k|    case ' ':
  ------------------
  |  Branch (152:5): [True: 104k, False: 277k]
  ------------------
  153|   113k|    case ',':
  ------------------
  |  Branch (153:5): [True: 3.67k, False: 377k]
  ------------------
  154|   124k|    case ']':
  ------------------
  |  Branch (154:5): [True: 10.7k, False: 370k]
  ------------------
  155|   124k|    case '}':
  ------------------
  |  Branch (155:5): [True: 197, False: 381k]
  ------------------
  156|   124k|      goto found;
  157|   257k|    default:
  ------------------
  |  Branch (157:5): [True: 257k, False: 124k]
  ------------------
  158|       |                   /* to quiet a warning from gcc*/
  159|   257k|      break;
  160|   381k|    }
  161|   257k|    if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
  ------------------
  |  Branch (161:9): [True: 8, False: 257k]
  |  Branch (161:33): [True: 1, False: 257k]
  ------------------
  162|      9|      parser->pos = start;
  163|      9|      return JSMN_ERROR_INVAL;
  164|      9|    }
  165|   257k|  }
  166|    160|#ifdef JSMN_STRICT
  167|       |  /* In strict mode primitive must be followed by a comma/object/array */
  168|    160|  parser->pos = start;
  169|    160|  return JSMN_ERROR_PART;
  170|      0|#endif
  171|       |
  172|   124k|found:
  173|   124k|  if (tokens == NULL) {
  ------------------
  |  Branch (173:7): [True: 0, False: 124k]
  ------------------
  174|      0|    parser->pos--;
  175|      0|    return 0;
  176|      0|  }
  177|   124k|  token = jsmn_alloc_token(parser, tokens, num_tokens);
  178|   124k|  if (token == NULL) {
  ------------------
  |  Branch (178:7): [True: 408, False: 124k]
  ------------------
  179|    408|    parser->pos = start;
  180|    408|    return JSMN_ERROR_NOMEM;
  181|    408|  }
  182|   124k|  jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
  183|   124k|#ifdef JSMN_PARENT_LINKS
  184|   124k|  token->parent = parser->toksuper;
  185|   124k|#endif
  186|   124k|  parser->pos--;
  187|   124k|  return 0;
  188|   124k|}

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|    894|{
  711|    894|    static const unsigned char d = 0xc2;
  712|    894|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|    894|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  713|    894|}
flb_pack.c:msgpack_pack_true:
  704|    805|{
  705|    805|    static const unsigned char d = 0xc3;
  706|    805|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|    805|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  707|    805|}
flb_pack.c:msgpack_pack_nil:
  693|    858|{
  694|    858|    static const unsigned char d = 0xc0;
  695|    858|    msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|    858|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  696|    858|}
flb_pack.c:msgpack_pack_int64:
  376|  16.8k|{
  377|  16.8k|    msgpack_pack_real_int64(x, d);
  ------------------
  |  |  221|  16.8k|#define msgpack_pack_real_int64(x, d) \
  |  |  222|  16.8k|do { \
  |  |  223|  16.8k|    if(d < -(1LL<<5)) { \
  |  |  ------------------
  |  |  |  Branch (223:8): [True: 1.35k, False: 15.4k]
  |  |  ------------------
  |  |  224|  1.35k|        if(d < -(1LL<<15)) { \
  |  |  ------------------
  |  |  |  Branch (224:12): [True: 687, False: 665]
  |  |  ------------------
  |  |  225|    687|            if(d < -(1LL<<31)) { \
  |  |  ------------------
  |  |  |  Branch (225:16): [True: 349, False: 338]
  |  |  ------------------
  |  |  226|    349|                /* signed 64 */ \
  |  |  227|    349|                unsigned char buf[9]; \
  |  |  228|    349|                buf[0] = 0xd3; _msgpack_store64(&buf[1], d); \
  |  |  ------------------
  |  |  |  |  186|    349|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    349|#        define _msgpack_be64(x) bswap_64(x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  229|    349|                msgpack_pack_append_buffer(x, buf, 9); \
  |  |  ------------------
  |  |  |  |  126|    349|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  230|    349|            } else { \
  |  |  231|    338|                /* signed 32 */ \
  |  |  232|    338|                unsigned char buf[5]; \
  |  |  233|    338|                buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
  |  |  ------------------
  |  |  |  |  184|    338|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  124|    338|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  234|    338|                msgpack_pack_append_buffer(x, buf, 5); \
  |  |  ------------------
  |  |  |  |  126|    338|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  235|    338|            } \
  |  |  236|    687|        } else { \
  |  |  237|    665|            if(d < -(1<<7)) { \
  |  |  ------------------
  |  |  |  Branch (237:16): [True: 385, False: 280]
  |  |  ------------------
  |  |  238|    385|                /* signed 16 */ \
  |  |  239|    385|                unsigned char buf[3]; \
  |  |  240|    385|                buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
  |  |  ------------------
  |  |  |  |  182|    385|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    385|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  241|    385|                msgpack_pack_append_buffer(x, buf, 3); \
  |  |  ------------------
  |  |  |  |  126|    385|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  242|    385|            } else { \
  |  |  243|    280|                /* signed 8 */ \
  |  |  244|    280|                unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \
  |  |  ------------------
  |  |  |  |   22|    280|#define TAKE8_64(d) ((uint8_t*)&d)[0]
  |  |  ------------------
  |  |  245|    280|                msgpack_pack_append_buffer(x, buf, 2); \
  |  |  ------------------
  |  |  |  |  126|    280|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  246|    280|            } \
  |  |  247|    665|        } \
  |  |  248|  15.4k|    } else if(d < (1<<7)) { \
  |  |  ------------------
  |  |  |  Branch (248:15): [True: 14.1k, False: 1.29k]
  |  |  ------------------
  |  |  249|  14.1k|        /* fixnum */ \
  |  |  250|  14.1k|        msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
  |  |  ------------------
  |  |  |  |  126|  14.1k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  251|  14.1k|    } else { \
  |  |  252|  1.29k|        if(d < (1LL<<16)) { \
  |  |  ------------------
  |  |  |  Branch (252:12): [True: 645, False: 653]
  |  |  ------------------
  |  |  253|    645|            if(d < (1<<8)) { \
  |  |  ------------------
  |  |  |  Branch (253:16): [True: 238, False: 407]
  |  |  ------------------
  |  |  254|    238|                /* unsigned 8 */ \
  |  |  255|    238|                unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
  |  |  ------------------
  |  |  |  |   22|    238|#define TAKE8_64(d) ((uint8_t*)&d)[0]
  |  |  ------------------
  |  |  256|    238|                msgpack_pack_append_buffer(x, buf, 2); \
  |  |  ------------------
  |  |  |  |  126|    238|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  257|    407|            } else { \
  |  |  258|    407|                /* unsigned 16 */ \
  |  |  259|    407|                unsigned char buf[3]; \
  |  |  260|    407|                buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
  |  |  ------------------
  |  |  |  |  182|    407|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    407|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  261|    407|                msgpack_pack_append_buffer(x, buf, 3); \
  |  |  ------------------
  |  |  |  |  126|    407|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  262|    407|            } \
  |  |  263|    653|        } else { \
  |  |  264|    653|            if(d < (1LL<<32)) { \
  |  |  ------------------
  |  |  |  Branch (264:16): [True: 333, False: 320]
  |  |  ------------------
  |  |  265|    333|                /* unsigned 32 */ \
  |  |  266|    333|                unsigned char buf[5]; \
  |  |  267|    333|                buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
  |  |  ------------------
  |  |  |  |  184|    333|    do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  124|    333|#       define _msgpack_be32(x) ntohl((uint32_t)x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (184:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  268|    333|                msgpack_pack_append_buffer(x, buf, 5); \
  |  |  ------------------
  |  |  |  |  126|    333|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  269|    333|            } else { \
  |  |  270|    320|                /* unsigned 64 */ \
  |  |  271|    320|                unsigned char buf[9]; \
  |  |  272|    320|                buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
  |  |  ------------------
  |  |  |  |  186|    320|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  |  142|    320|#        define _msgpack_be64(x) bswap_64(x)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  273|    320|                msgpack_pack_append_buffer(x, buf, 9); \
  |  |  ------------------
  |  |  |  |  126|    320|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  |  |  ------------------
  |  |  274|    320|            } \
  |  |  275|    653|        } \
  |  |  276|  1.29k|    } \
  |  |  277|  16.8k|} while(0)
  |  |  ------------------
  |  |  |  Branch (277:9): [Folded - Ignored]
  |  |  ------------------
  ------------------
  378|  16.8k|}
flb_pack.c:msgpack_pack_array:
  721|  11.5k|{
  722|  11.5k|    if(n < 16) {
  ------------------
  |  Branch (722:8): [True: 10.9k, False: 527]
  ------------------
  723|  10.9k|        unsigned char d = 0x90 | (uint8_t)n;
  724|  10.9k|        msgpack_pack_append_buffer(x, &d, 1);
  ------------------
  |  |  126|  10.9k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  725|  10.9k|    } else if(n < 65536) {
  ------------------
  |  Branch (725:15): [True: 527, False: 0]
  ------------------
  726|    527|        unsigned char buf[3];
  727|    527|        buf[0] = 0xdc; _msgpack_store16(&buf[1], (uint16_t)n);
  ------------------
  |  |  182|    527|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|    527|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  728|    527|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|    527|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  729|    527|    } 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.5k|}
flb_pack.c:msgpack_pack_map:
  742|  8.29k|{
  743|  8.29k|    if(n < 16) {
  ------------------
  |  Branch (743:8): [True: 8.17k, False: 117]
  ------------------
  744|  8.17k|        unsigned char d = 0x80 | (uint8_t)n;
  745|  8.17k|        msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
  ------------------
  |  |  126|  8.17k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  746|  8.17k|    } else if(n < 65536) {
  ------------------
  |  Branch (746:15): [True: 117, False: 0]
  ------------------
  747|    117|        unsigned char buf[3];
  748|    117|        buf[0] = 0xde; _msgpack_store16(&buf[1], (uint16_t)n);
  ------------------
  |  |  182|    117|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|    117|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  749|    117|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|    117|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  750|    117|    } 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|  8.29k|}
flb_pack.c:msgpack_pack_str:
  763|  13.3k|{
  764|  13.3k|    if(l < 32) {
  ------------------
  |  Branch (764:8): [True: 13.1k, False: 239]
  ------------------
  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: 161, False: 78]
  ------------------
  768|    161|        unsigned char buf[2];
  769|    161|        buf[0] = 0xd9; buf[1] = (uint8_t)l;
  770|    161|        msgpack_pack_append_buffer(x, buf, 2);
  ------------------
  |  |  126|    161|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  771|    161|    } else if(l < 65536) {
  ------------------
  |  Branch (771:15): [True: 78, False: 0]
  ------------------
  772|     78|        unsigned char buf[3];
  773|     78|        buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
  ------------------
  |  |  182|     78|    do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
  |  |  ------------------
  |  |  |  |  110|     78|#       define _msgpack_be16(x) ntohs((uint16_t)x)
  |  |  ------------------
  |  |  |  Branch (182:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  774|     78|        msgpack_pack_append_buffer(x, buf, 3);
  ------------------
  |  |  126|     78|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  775|     78|    } 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|   102k|{
  673|   102k|    unsigned char buf[9];
  674|   102k|    union { double f; uint64_t i; } mem;
  675|   102k|    mem.f = d;
  676|   102k|    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|   102k|    _msgpack_store64(&buf[1], mem.i);
  ------------------
  |  |  186|   102k|    do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
  |  |  ------------------
  |  |  |  |  142|   102k|#        define _msgpack_be64(x) bswap_64(x)
  |  |  ------------------
  |  |  |  Branch (186:74): [Folded - Ignored]
  |  |  ------------------
  ------------------
  684|   102k|    msgpack_pack_append_buffer(x, buf, 9);
  ------------------
  |  |  126|   102k|    return (*(user)->callback)((user)->data, (const char*)buf, len)
  ------------------
  685|   102k|}

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|   168k|{
   62|   168k|    msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
   63|       |
   64|   168k|    assert(buf || len == 0);
   65|   168k|    if(!buf) return 0;
  ------------------
  |  Branch (65:8): [True: 0, False: 168k]
  ------------------
   66|       |
   67|   168k|    if(sbuf->alloc - sbuf->size < len) {
  ------------------
  |  Branch (67:8): [True: 1.51k, False: 167k]
  ------------------
   68|  1.51k|        void* tmp;
   69|  1.51k|        size_t nsize = (sbuf->alloc) ?
  ------------------
  |  Branch (69:24): [True: 30, 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|   168k|    memcpy(sbuf->data + sbuf->size, buf, len);
   89|   168k|    sbuf->size += len;
   90|       |
   91|   168k|    return 0;
   92|   168k|}

flb_json_tokenise:
   55|  2.00k|{
   56|  2.00k|    int ret;
   57|  2.00k|    int new_tokens = 256;
   58|  2.00k|    size_t old_size;
   59|  2.00k|    size_t new_size;
   60|  2.00k|    void *tmp;
   61|       |
   62|  2.00k|    ret = jsmn_parse(&state->parser, js, len,
   63|  2.00k|                     state->tokens, state->tokens_size);
   64|  2.84k|    while (ret == JSMN_ERROR_NOMEM) {
  ------------------
  |  Branch (64:12): [True: 838, False: 2.00k]
  ------------------
   65|       |        /* Get current size of the array in bytes */
   66|    838|        old_size = state->tokens_size * sizeof(jsmntok_t);
   67|       |
   68|       |        /* New size: add capacity for new 256 entries */
   69|    838|        new_size = old_size + (sizeof(jsmntok_t) * new_tokens);
   70|       |
   71|    838|        tmp = flb_realloc(state->tokens, new_size);
   72|    838|        if (!tmp) {
  ------------------
  |  Branch (72:13): [True: 0, False: 838]
  ------------------
   73|      0|            flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
   74|      0|            return -1;
   75|      0|        }
   76|    838|        state->tokens = tmp;
   77|    838|        state->tokens_size += new_tokens;
   78|       |
   79|    838|        ret = jsmn_parse(&state->parser, js, len,
   80|    838|                         state->tokens, state->tokens_size);
   81|    838|    }
   82|       |
   83|  2.00k|    if (ret == JSMN_ERROR_INVAL) {
  ------------------
  |  Branch (83:9): [True: 89, False: 1.91k]
  ------------------
   84|     89|        return FLB_ERR_JSON_INVAL;
  ------------------
  |  |   45|     89|#define FLB_ERR_JSON_INVAL           -501
  ------------------
   85|     89|    }
   86|       |
   87|  1.91k|    if (ret == JSMN_ERROR_PART) {
  ------------------
  |  Branch (87:9): [True: 505, False: 1.41k]
  ------------------
   88|       |        /* This is a partial JSON message, just stop */
   89|    505|        flb_trace("[json tokenise] incomplete");
  ------------------
  |  |  193|    505|#define flb_trace(fmt, ...)  do {} while(0)
  |  |  ------------------
  |  |  |  Branch (193:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
   90|    505|        return FLB_ERR_JSON_PART;
  ------------------
  |  |   46|    505|#define FLB_ERR_JSON_PART            -502
  ------------------
   91|    505|    }
   92|       |
   93|  1.41k|    state->tokens_count += ret;
   94|  1.41k|    return 0;
   95|  1.91k|}
flb_pack_state_init:
  304|  2.00k|{
  305|  2.00k|    int tokens = 256;
  306|  2.00k|    size_t size = 256;
  307|       |
  308|  2.00k|    jsmn_init(&s->parser);
  309|       |
  310|  2.00k|    size = sizeof(jsmntok_t) * tokens;
  311|  2.00k|    s->tokens = flb_malloc(size);
  312|  2.00k|    if (!s->tokens) {
  ------------------
  |  Branch (312:9): [True: 0, False: 2.00k]
  ------------------
  313|      0|        flb_errno();
  ------------------
  |  |  201|      0|#define flb_errno() flb_errno_print(errno, __FLB_FILENAME__, __LINE__)
  ------------------
  314|      0|        return -1;
  315|      0|    }
  316|  2.00k|    s->tokens_size   = tokens;
  317|  2.00k|    s->tokens_count  = 0;
  318|  2.00k|    s->last_byte     = 0;
  319|  2.00k|    s->multiple      = FLB_FALSE;
  ------------------
  |  |   25|  2.00k|#define FLB_FALSE  0
  ------------------
  320|       |
  321|  2.00k|    s->buf_data = flb_malloc(size);
  322|  2.00k|    if (!s->buf_data) {
  ------------------
  |  Branch (322:9): [True: 0, False: 2.00k]
  ------------------
  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.00k|    s->buf_size = size;
  329|  2.00k|    s->buf_len = 0;
  330|       |
  331|  2.00k|    return 0;
  332|  2.00k|}
flb_pack_state_reset:
  335|  2.00k|{
  336|  2.00k|    flb_free(s->tokens);
  337|  2.00k|    s->tokens = NULL;
  338|  2.00k|    s->tokens_size  = 0;
  339|  2.00k|    s->tokens_count = 0;
  340|  2.00k|    s->last_byte    = 0;
  341|  2.00k|    s->buf_size     = 0;
  342|  2.00k|    flb_free(s->buf_data);
  343|  2.00k|    s->buf_data = NULL;
  344|  2.00k|}
flb_pack_json_state:
  356|  2.00k|{
  357|  2.00k|    int ret;
  358|  2.00k|    int out;
  359|  2.00k|    int delim = 0;
  360|  2.00k|    int last =  0;
  361|  2.00k|    int records;
  362|  2.00k|    char *buf;
  363|  2.00k|    jsmntok_t *t;
  364|       |
  365|  2.00k|    ret = flb_json_tokenise(js, len, state);
  366|  2.00k|    state->multiple = FLB_TRUE;
  ------------------
  |  |   26|  2.00k|#define FLB_TRUE   !FLB_FALSE
  |  |  ------------------
  |  |  |  |   25|  2.00k|#define FLB_FALSE  0
  |  |  ------------------
  ------------------
  367|  2.00k|    if (ret == FLB_ERR_JSON_PART && state->multiple == FLB_TRUE) {
  ------------------
  |  |   46|  4.01k|#define FLB_ERR_JSON_PART            -502
  ------------------
                  if (ret == FLB_ERR_JSON_PART && state->multiple == FLB_TRUE) {
  ------------------
  |  |   26|    505|#define FLB_TRUE   !FLB_FALSE
  |  |  ------------------
  |  |  |  |   25|    505|#define FLB_FALSE  0
  |  |  ------------------
  ------------------
  |  Branch (367:9): [True: 505, False: 1.50k]
  |  Branch (367:37): [True: 505, 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|    505|        int i;
  384|    505|        int found = 0;
  385|       |
  386|    505|        if (state->parser.toknext == 0) {
  ------------------
  |  Branch (386:13): [True: 175, False: 330]
  ------------------
  387|    175|            return ret;
  388|    175|        }
  389|       |
  390|   108k|        for (i = (int)state->parser.toknext - 1; i >= 1; i--) {
  ------------------
  |  Branch (390:50): [True: 108k, False: 211]
  ------------------
  391|   108k|            t = &state->tokens[i];
  392|       |
  393|   108k|            if (t->parent == -1 && (t->end != 0)) {
  ------------------
  |  Branch (393:17): [True: 119, False: 108k]
  |  Branch (393:36): [True: 119, False: 0]
  ------------------
  394|    119|                found++;
  395|    119|                delim = i;
  396|    119|                break;
  397|    119|            }
  398|   108k|        }
  399|       |
  400|    330|        if (found == 0) {
  ------------------
  |  Branch (400:13): [True: 211, False: 119]
  ------------------
  401|    211|            return ret; /* FLB_ERR_JSON_PART */
  402|    211|        }
  403|    119|        state->tokens_count += delim;
  404|    119|    }
  405|  1.50k|    else if (ret != 0) {
  ------------------
  |  Branch (405:14): [True: 89, False: 1.41k]
  ------------------
  406|     89|        return ret;
  407|     89|    }
  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|   156k|    for (i = 0; i < arr_size ; i++) {
  ------------------
  |  Branch (177:17): [True: 155k, False: 1.48k]
  ------------------
  178|   155k|        t = &tokens[i];
  179|       |
  180|   155k|        if (t->start == -1 || t->end == -1 || (t->start == 0 && t->end == 0)) {
  ------------------
  |  Branch (180:13): [True: 0, False: 155k]
  |  Branch (180:31): [True: 0, False: 155k]
  |  Branch (180:48): [True: 1.12k, False: 154k]
  |  Branch (180:65): [True: 0, False: 1.12k]
  ------------------
  181|      0|            break;
  182|      0|        }
  183|       |
  184|   155k|        if (t->parent == -1) {
  ------------------
  |  Branch (184:13): [True: 105k, False: 50.1k]
  ------------------
  185|   105k|            *last_byte = t->end;
  186|   105k|            records++;
  187|   105k|        }
  188|       |
  189|   155k|        flen = (t->end - t->start);
  190|   155k|        switch (t->type) {
  ------------------
  |  Branch (190:17): [True: 0, False: 155k]
  ------------------
  191|  8.29k|        case JSMN_OBJECT:
  ------------------
  |  Branch (191:9): [True: 8.29k, False: 147k]
  ------------------
  192|  8.29k|            msgpack_pack_map(&pck, t->size);
  193|  8.29k|            break;
  194|  11.5k|        case JSMN_ARRAY:
  ------------------
  |  Branch (194:9): [True: 11.5k, False: 143k]
  ------------------
  195|  11.5k|            msgpack_pack_array(&pck, t->size);
  196|  11.5k|            break;
  197|  13.3k|        case JSMN_STRING:
  ------------------
  |  Branch (197:9): [True: 13.3k, False: 142k]
  ------------------
  198|  13.3k|            pack_string_token(state, js + t->start, flen, &pck);
  199|  13.3k|            break;
  200|   122k|        case JSMN_PRIMITIVE:
  ------------------
  |  Branch (200:9): [True: 122k, False: 33.1k]
  ------------------
  201|   122k|            p = js + t->start;
  202|   122k|            if (*p == 'f') {
  ------------------
  |  Branch (202:17): [True: 894, False: 121k]
  ------------------
  203|    894|                msgpack_pack_false(&pck);
  204|    894|            }
  205|   121k|            else if (*p == 't') {
  ------------------
  |  Branch (205:22): [True: 805, False: 120k]
  ------------------
  206|    805|                msgpack_pack_true(&pck);
  207|    805|            }
  208|   120k|            else if (*p == 'n') {
  ------------------
  |  Branch (208:22): [True: 858, False: 119k]
  ------------------
  209|    858|                msgpack_pack_nil(&pck);
  210|    858|            }
  211|   119k|            else {
  212|   119k|                if (is_float(p, flen)) {
  ------------------
  |  Branch (212:21): [True: 102k, False: 16.8k]
  ------------------
  213|   102k|                    msgpack_pack_double(&pck, atof(p));
  214|   102k|                }
  215|  16.8k|                else {
  216|  16.8k|                    msgpack_pack_int64(&pck, atoll(p));
  217|  16.8k|                }
  218|   119k|            }
  219|   122k|            break;
  220|      0|        case JSMN_UNDEFINED:
  ------------------
  |  Branch (220:9): [True: 0, False: 155k]
  ------------------
  221|      0|            msgpack_sbuffer_destroy(&sbuf);
  222|      0|            return NULL;
  223|   155k|        }
  224|   155k|    }
  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|   282k|    while (p <= end) {
  ------------------
  |  Branch (102:12): [True: 266k, False: 16.8k]
  ------------------
  103|   266k|        if (*p == 'e' && p < end && *(p + 1) == '-') {
  ------------------
  |  Branch (103:13): [True: 406, False: 265k]
  |  Branch (103:26): [True: 406, False: 0]
  |  Branch (103:37): [True: 194, False: 212]
  ------------------
  104|    194|            return 1;
  105|    194|        }
  106|   265k|        else if (*p == '.') {
  ------------------
  |  Branch (106:18): [True: 102k, False: 163k]
  ------------------
  107|   102k|            return 1;
  108|   102k|        }
  109|   163k|        p++;
  110|   163k|    }
  111|       |
  112|  16.8k|    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|  93.6k|    while (in_buf < end && *in_buf && count_in < sz) {
  ------------------
  |  Branch (142:12): [True: 80.3k, False: 13.3k]
  |  Branch (142:28): [True: 80.3k, False: 0]
  |  Branch (142:39): [True: 80.3k, False: 0]
  ------------------
  143|  80.3k|        next = in_buf + 1;
  144|  80.3k|        if (next < end && *in_buf == '\\') {
  ------------------
  |  Branch (144:13): [True: 79.6k, False: 650]
  |  Branch (144:27): [True: 3.67k, False: 75.9k]
  ------------------
  145|  3.67k|            esc_in = 2;
  146|  3.67k|            switch (*next) {
  147|    242|            case '"':
  ------------------
  |  Branch (147:13): [True: 242, False: 3.43k]
  ------------------
  148|    242|                ch = '"';
  149|    242|                break;
  150|      0|            case '\'':
  ------------------
  |  Branch (150:13): [True: 0, False: 3.67k]
  ------------------
  151|      0|                ch = '\'';
  152|      0|                break;
  153|    264|            case '\\':
  ------------------
  |  Branch (153:13): [True: 264, False: 3.41k]
  ------------------
  154|    264|                ch = '\\';
  155|    264|                break;
  156|    343|            case '/':
  ------------------
  |  Branch (156:13): [True: 343, False: 3.33k]
  ------------------
  157|    343|                ch = '/';
  158|    343|                break;
  159|    221|            case 'n':
  ------------------
  |  Branch (159:13): [True: 221, False: 3.45k]
  ------------------
  160|    221|                ch = '\n';
  161|    221|                break;
  162|    258|            case 'b':
  ------------------
  |  Branch (162:13): [True: 258, False: 3.41k]
  ------------------
  163|    258|                ch = '\b';
  164|    258|                break;
  165|    237|            case 't':
  ------------------
  |  Branch (165:13): [True: 237, False: 3.44k]
  ------------------
  166|    237|                ch = '\t';
  167|    237|                break;
  168|    213|            case 'f':
  ------------------
  |  Branch (168:13): [True: 213, False: 3.46k]
  ------------------
  169|    213|                ch = '\f';
  170|    213|                break;
  171|    194|            case 'r':
  ------------------
  |  Branch (171:13): [True: 194, False: 3.48k]
  ------------------
  172|    194|                ch = '\r';
  173|    194|                break;
  174|  1.70k|            default:
  ------------------
  |  Branch (174:13): [True: 1.70k, False: 1.97k]
  ------------------
  175|  1.70k|                size = end - next;
  176|  1.70k|                if (size > 0) {
  ------------------
  |  Branch (176:21): [True: 1.70k, False: 0]
  ------------------
  177|  1.70k|                    esc_in = u8_read_escape_sequence(next, size, &ch) + 1;
  178|  1.70k|                }
  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|  3.67k|            }
  185|  3.67k|        }
  186|  76.6k|        else {
  187|       |            /* explicit convert char to signed char */
  188|  76.6k|            ch = (uint32_t) (signed char) *in_buf;
  189|  76.6k|            esc_in = 1;
  190|  76.6k|        }
  191|       |
  192|  80.3k|        in_buf += esc_in;
  193|  80.3k|        count_in += esc_in;
  194|       |
  195|  80.3k|        esc_out = u8_wc_toutf8(temp, ch);
  196|  80.3k|        if (esc_out > sz-count_out) {
  ------------------
  |  Branch (196:13): [True: 0, False: 80.3k]
  ------------------
  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|  80.3k|        if (esc_out == 0) {
  ------------------
  |  Branch (201:13): [True: 15.0k, False: 65.2k]
  ------------------
  202|  15.0k|            out_buf[count_out] = ch;
  203|  15.0k|            esc_out = 1;
  204|  15.0k|        }
  205|  65.2k|        else if (esc_out == 1) {
  ------------------
  |  Branch (205:18): [True: 63.5k, False: 1.70k]
  ------------------
  206|  63.5k|            out_buf[count_out] = (char) temp[0];
  207|  63.5k|        }
  208|  1.70k|        else {
  209|  1.70k|            memcpy(&out_buf[count_out], temp, esc_out);
  210|  1.70k|        }
  211|  80.3k|        count_out += esc_out;
  212|  80.3k|    }
  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|  1.70k|{
   71|  1.70k|    uint32_t ch;
   72|  1.70k|    char digs[9]="\0\0\0\0\0\0\0\0";
   73|  1.70k|    int dno=0, i=1;
   74|       |
   75|  1.70k|    ch = (uint32_t)str[0];    /* take literal character */
   76|       |
   77|  1.70k|    if (str[0] == 'n')
  ------------------
  |  Branch (77:9): [True: 0, False: 1.70k]
  ------------------
   78|      0|        ch = L'\n';
   79|  1.70k|    else if (str[0] == 't')
  ------------------
  |  Branch (79:14): [True: 0, False: 1.70k]
  ------------------
   80|      0|        ch = L'\t';
   81|  1.70k|    else if (str[0] == 'r')
  ------------------
  |  Branch (81:14): [True: 0, False: 1.70k]
  ------------------
   82|      0|        ch = L'\r';
   83|  1.70k|    else if (str[0] == 'b')
  ------------------
  |  Branch (83:14): [True: 0, False: 1.70k]
  ------------------
   84|      0|        ch = L'\b';
   85|  1.70k|    else if (str[0] == 'f')
  ------------------
  |  Branch (85:14): [True: 0, False: 1.70k]
  ------------------
   86|      0|        ch = L'\f';
   87|  1.70k|    else if (str[0] == 'v')
  ------------------
  |  Branch (87:14): [True: 0, False: 1.70k]
  ------------------
   88|      0|        ch = L'\v';
   89|  1.70k|    else if (str[0] == 'a')
  ------------------
  |  Branch (89:14): [True: 0, False: 1.70k]
  ------------------
   90|      0|        ch = L'\a';
   91|  1.70k|    else if (octal_digit(str[0])) {
  ------------------
  |  Branch (91:14): [True: 0, False: 1.70k]
  ------------------
   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|  1.70k|    else if (str[0] == 'x') {
  ------------------
  |  Branch (98:14): [True: 0, False: 1.70k]
  ------------------
   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|  1.70k|    else if (str[0] == 'u') {
  ------------------
  |  Branch (106:14): [True: 1.70k, False: 0]
  ------------------
  107|  8.52k|        while (i < size && hex_digit(str[i]) && dno < 4) {
  ------------------
  |  Branch (107:16): [True: 8.26k, False: 259]
  |  Branch (107:28): [True: 7.18k, False: 1.08k]
  |  Branch (107:49): [True: 6.82k, False: 365]
  ------------------
  108|  6.82k|            digs[dno++] = str[i++];
  109|  6.82k|        }
  110|  1.70k|        if (dno > 0) {
  ------------------
  |  Branch (110:13): [True: 1.70k, False: 0]
  ------------------
  111|  1.70k|            ch = strtol(digs, NULL, 16);
  112|  1.70k|        }
  113|  1.70k|    }
  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|  1.70k|    *dest = ch;
  123|       |
  124|  1.70k|    return i;
  125|  1.70k|}
flb_unescape.c:octal_digit:
   29|  1.70k|{
   30|  1.70k|    return (c >= '0' && c <= '7');
  ------------------
  |  Branch (30:13): [True: 1.70k, False: 0]
  |  Branch (30:25): [True: 0, False: 1.70k]
  ------------------
   31|  1.70k|}
flb_unescape.c:hex_digit:
   34|  8.26k|{
   35|  8.26k|    return ((c >= '0' && c <= '9') ||
  ------------------
  |  Branch (35:14): [True: 7.86k, False: 405]
  |  Branch (35:26): [True: 3.91k, False: 3.94k]
  ------------------
   36|  8.26k|            (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (36:14): [True: 3.93k, False: 412]
  |  Branch (36:26): [True: 1.65k, False: 2.28k]
  ------------------
   37|  8.26k|            (c >= 'a' && c <= 'f'));
  ------------------
  |  Branch (37:14): [True: 1.63k, False: 1.05k]
  |  Branch (37:26): [True: 1.61k, False: 24]
  ------------------
   38|  8.26k|}
flb_unescape.c:u8_wc_toutf8:
   41|  80.3k|{
   42|  80.3k|    if (ch < 0x80) {
  ------------------
  |  Branch (42:9): [True: 63.5k, False: 16.7k]
  ------------------
   43|  63.5k|        dest[0] = (char)ch;
   44|  63.5k|        return 1;
   45|  63.5k|    }
   46|  16.7k|    if (ch < 0x800) {
  ------------------
  |  Branch (46:9): [True: 593, False: 16.1k]
  ------------------
   47|    593|        dest[0] = (ch>>6) | 0xC0;
   48|    593|        dest[1] = (ch & 0x3F) | 0x80;
   49|    593|        return 2;
   50|    593|    }
   51|  16.1k|    if (ch < 0x10000) {
  ------------------
  |  Branch (51:9): [True: 1.10k, False: 15.0k]
  ------------------
   52|  1.10k|        dest[0] = (ch>>12) | 0xE0;
   53|  1.10k|        dest[1] = ((ch>>6) & 0x3F) | 0x80;
   54|  1.10k|        dest[2] = (ch & 0x3F) | 0x80;
   55|  1.10k|        return 3;
   56|  1.10k|    }
   57|  15.0k|    if (ch < 0x110000) {
  ------------------
  |  Branch (57:9): [True: 0, False: 15.0k]
  ------------------
   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|  15.0k|    return 0;
   65|  15.0k|}

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

