Branch Coverage

src/pdfmake_image.c
Criterion Covered Total %
branch 72 176 40.9


line true false branch
33 4 0 if (len < 2 || data[0] != 0xFF || data[1] != 0xD8)
4 0 if (len < 2 || data[0] != 0xFF || data[1] != 0xD8)
0 4 if (len < 2 || data[0] != 0xFF || data[1] != 0xD8)
37 12 0 while (pos + 4 <= len) {
38 0 12 if (data[pos] != 0xFF) return 0;
44 12 0 if (marker == 0x00 || marker == 0x01 || (marker >= 0xD0 && marker <= 0xD7))
12 0 if (marker == 0x00 || marker == 0x01 || (marker >= 0xD0 && marker <= 0xD7))
8 4 if (marker == 0x00 || marker == 0x01 || (marker >= 0xD0 && marker <= 0xD7))
0 8 if (marker == 0x00 || marker == 0x01 || (marker >= 0xD0 && marker <= 0xD7))
47 0 12 if (marker == 0xD9) break; /* EOI */
49 0 12 if (pos + 2 > len) return 0;
51 0 12 if (seg_len < 2) return 0;
54 8 4 if (marker == 0xC0 || marker == 0xC1 || marker == 0xC2) {
8 0 if (marker == 0xC0 || marker == 0xC1 || marker == 0xC2) {
0 8 if (marker == 0xC0 || marker == 0xC1 || marker == 0xC2) {
55 4 0 if (pos + seg_len > len || seg_len < 8) return 0;
0 4 if (pos + seg_len > len || seg_len < 8) return 0;
75 4 0 if (!bytes || len < 4) return NULL;
0 4 if (!bytes || len < 4) return NULL;
77 0 4 if (!jpeg_parse_header(bytes, len, &w, &h, &comp, &bpc))
81 0 4 if (!img) return NULL;
99 0 4 if (!img->data) { free(img); return NULL; }
157 15 0 if (!bytes || len < 33) return NULL;
0 15 if (!bytes || len < 33) return NULL;
158 0 15 if (memcmp(bytes, PNG_SIG, 8) != 0) return NULL;
163 15 0 if (memcmp(bytes + pos + 4, "IHDR", 4) != 0 || ihdr_len != 13)
0 15 if (memcmp(bytes + pos + 4, "IHDR", 4) != 0 || ihdr_len != 13)
173 0 15 if (interlace != 0) return NULL; /* Adam7 not supported */
174 0 15 if (bit_depth != 8 && bit_depth != 16) return NULL; /* Simplification */
0 0 if (bit_depth != 8 && bit_depth != 16) return NULL; /* Simplification */
198 90 0 while (pos + 12 <= len) {
203 0 90 if (pos + 12 + chunk_len > len) break;
205 60 30 if (memcmp(chunk_type, "IDAT", 4) == 0) {
208 15 15 else if (memcmp(chunk_type, "PLTE", 4) == 0) {
210 15 0 if (palette) {
215 0 15 else if (memcmp(chunk_type, "tRNS", 4) == 0) {
217 0 0 if (trns) {
222 15 0 else if (memcmp(chunk_type, "IEND", 4) == 0) {
229 0 15 if (idat_buf.len == 0) {
240 0 15 if (pdfmake_flate_decode(idat_buf.data, idat_buf.len, ¶ms, &raw_buf) != PDFMAKE_OK) {
251 0 15 if (pdfmake_predictor_decode(15, components, bit_depth, w,
268 0 15 if (has_alpha) {
277 0 0 if (!color_data || !alpha_data) {
0 0 if (!color_data || !alpha_data) {
285 0 0 for (row = 0; row < h; row++) {
289 0 0 for (col = 0; col < w; col++) {
302 0 15 if (!color_data) {
315 0 15 enc_params.colors = (cs == PDFMAKE_IMAGE_INDEXED) ? 1 : components;
319 0 15 if (pdfmake_flate_encode(color_data, color_len, &enc_params, &encoded) != PDFMAKE_OK) {
330 0 15 if (alpha_data) {
338 0 0 if (pdfmake_flate_encode(alpha_data, alpha_len, &smask_params, &smask_buf) == PDFMAKE_OK) {
348 0 15 if (!img) {
386 0 0 if (!doc || !raw || !raw->pixels) return NULL;
0 0 if (!doc || !raw || !raw->pixels) return NULL;
0 0 if (!doc || !raw || !raw->pixels) return NULL;
389 0 0 if (!img) return NULL;
409 0 0 if (pdfmake_flate_encode(raw->pixels, raw->pixels_len, ¶ms, &encoded) != PDFMAKE_OK) {
419 0 0 if (raw->alpha && raw->alpha_len > 0) {
0 0 if (raw->alpha && raw->alpha_len > 0) {
422 0 0 if (pdfmake_flate_encode(raw->alpha, raw->alpha_len, ¶ms, &smask_buf) == PDFMAKE_OK) {
429 0 0 if (raw->palette && raw->palette_len > 0) {
0 0 if (raw->palette && raw->palette_len > 0) {
431 0 0 if (img->palette) {
445 19 0 if (!bytes || len < 8) return NULL;
0 19 if (!bytes || len < 8) return NULL;
448 4 15 if (bytes[0] == 0xFF && bytes[1] == 0xD8)
4 0 if (bytes[0] == 0xFF && bytes[1] == 0xD8)
452 15 0 if (memcmp(bytes, PNG_SIG, 8) == 0)
476 17 0 if (!img || !doc || !img->data) return 0;
17 0 if (!img || !doc || !img->data) return 0;
0 17 if (!img || !doc || !img->data) return 0;
481 0 17 if (img->has_alpha && img->smask_data) {
0 0 if (img->has_alpha && img->smask_data) {
483 0 0 if (smask_stream.kind != PDFMAKE_STREAM) return 0;
487 0 0 if (smask_stream.as.stream) {
512 0 0 if (img->format == PDFMAKE_IMAGE_PNG) {
530 0 0 if (img->smask_num == 0) return 0;
535 0 17 if (img_stream.kind != PDFMAKE_STREAM) return 0;
539 17 0 if (img_stream.as.stream && img->format != PDFMAKE_IMAGE_JPEG) {
15 2 if (img_stream.as.stream && img->format != PDFMAKE_IMAGE_JPEG) {
586 2 15 if (img->format == PDFMAKE_IMAGE_JPEG) {
592 15 0 if (img->format == PDFMAKE_IMAGE_PNG) {
608 0 17 if (img->smask_num) {
625 0 19 if (!img) return;
638 17 0 if (!page || !name || img_obj_num == 0) return -1;
17 0 if (!page || !name || img_obj_num == 0) return -1;
0 17 if (!page || !name || img_obj_num == 0) return -1;
639 0 17 if (page->image_count >= PDFMAKE_MAX_PAGE_IMAGES) return -1;