| 713 | } |
| 714 | |
| 715 | static void *cv2_array(cv2_context_t *ctx, size_t count, size_t size) { |
| 716 | if (!count) |
| 717 | return NULL; |
| 718 | if (size && count > SIZE_MAX / size) { |
| 719 | cv2_fail(ctx, CBM_COVERAGE_PARSE_LIMIT); |
| 720 | return NULL; |
| 721 | } |
| 722 | size_t bytes = count * size; |
| 723 | if (bytes > ctx->limits->max_alloc_bytes - ctx->allocated) { |
| 724 | cv2_fail(ctx, CBM_COVERAGE_PARSE_LIMIT); |
| 725 | return NULL; |
| 726 | } |
| 727 | if (!cv2_poll(ctx)) |
| 728 | return NULL; |
| 729 | ctx->allocated += bytes; |
| 730 | void *memory = cbm_arena_alloc(&ctx->arena, bytes); |
| 731 | if (!memory) { |
| 732 | cv2_fail(ctx, CBM_COVERAGE_PARSE_OOM); |
| 733 | return NULL; |
| 734 | } |
| 735 | return cv2_zero(ctx, memory, bytes) ? memory : NULL; |
| 736 | } |
| 737 | |
| 738 | static char *cv2_string(cv2_context_t *ctx, cv2_span_t span) { |
| 739 | if (span.length == SIZE_MAX) { |
no test coverage detected