| 828 | } |
| 829 | |
| 830 | static int agent_json_scan_array(agent_json_scanner_t *scanner, unsigned depth) { |
| 831 | if (depth >= AGENT_JSON_MAX_DEPTH) { |
| 832 | return -1; |
| 833 | } |
| 834 | scanner->position++; |
| 835 | if (agent_json_skip_space(scanner) != 0) { |
| 836 | return -1; |
| 837 | } |
| 838 | if (scanner->position < scanner->length && scanner->data[scanner->position] == ']') { |
| 839 | scanner->position++; |
| 840 | return 0; |
| 841 | } |
| 842 | for (;;) { |
| 843 | if (agent_json_scan_value(scanner, depth + 1U) != 0 || |
| 844 | agent_json_skip_space(scanner) != 0 || scanner->position >= scanner->length) { |
| 845 | return -1; |
| 846 | } |
| 847 | char separator = scanner->data[scanner->position++]; |
| 848 | if (separator == ']') { |
| 849 | return 0; |
| 850 | } |
| 851 | if (separator != ',' || agent_json_skip_space(scanner) != 0) { |
| 852 | return -1; |
| 853 | } |
| 854 | if (scanner->position < scanner->length && scanner->data[scanner->position] == ']') { |
| 855 | scanner->position++; |
| 856 | return 0; |
| 857 | } |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | static int agent_json_scan_value(agent_json_scanner_t *scanner, unsigned depth) { |
| 862 | if (depth > AGENT_JSON_MAX_DEPTH || agent_json_skip_space(scanner) != 0 || |
no test coverage detected