| 813 | } |
| 814 | |
| 815 | static int agent_json_scan_array(agent_json_scanner_t *scanner, unsigned depth) { |
| 816 | if (depth >= AGENT_JSON_MAX_DEPTH) { |
| 817 | return -1; |
| 818 | } |
| 819 | scanner->position++; |
| 820 | if (agent_json_skip_space(scanner) != 0) { |
| 821 | return -1; |
| 822 | } |
| 823 | if (scanner->position < scanner->length && scanner->data[scanner->position] == ']') { |
| 824 | scanner->position++; |
| 825 | return 0; |
| 826 | } |
| 827 | for (;;) { |
| 828 | if (agent_json_scan_value(scanner, depth + 1U) != 0 || |
| 829 | agent_json_skip_space(scanner) != 0 || scanner->position >= scanner->length) { |
| 830 | return -1; |
| 831 | } |
| 832 | char separator = scanner->data[scanner->position++]; |
| 833 | if (separator == ']') { |
| 834 | return 0; |
| 835 | } |
| 836 | if (separator != ',' || agent_json_skip_space(scanner) != 0) { |
| 837 | return -1; |
| 838 | } |
| 839 | if (scanner->position < scanner->length && scanner->data[scanner->position] == ']') { |
| 840 | scanner->position++; |
| 841 | return 0; |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | static int agent_json_scan_value(agent_json_scanner_t *scanner, unsigned depth) { |
| 847 | if (depth > AGENT_JSON_MAX_DEPTH || agent_json_skip_space(scanner) != 0 || |
no test coverage detected