| 2514 | } |
| 2515 | |
| 2516 | unsigned char* lodepng_chunk_next(unsigned char* chunk, unsigned char* end) { |
| 2517 | if(chunk >= end || end - chunk < 12) return end; /*too small to contain a chunk*/ |
| 2518 | if(chunk[0] == 0x89 && chunk[1] == 0x50 && chunk[2] == 0x4e && chunk[3] == 0x47 |
| 2519 | && chunk[4] == 0x0d && chunk[5] == 0x0a && chunk[6] == 0x1a && chunk[7] == 0x0a) { |
| 2520 | /* Is PNG magic header at start of PNG file. Jump to first actual chunk. */ |
| 2521 | return chunk + 8; |
| 2522 | } else { |
| 2523 | size_t total_chunk_length; |
| 2524 | unsigned char* result; |
| 2525 | if(lodepng_addofl(lodepng_chunk_length(chunk), 12, &total_chunk_length)) return end; |
| 2526 | result = chunk + total_chunk_length; |
| 2527 | if(result < chunk) return end; /*pointer overflow*/ |
| 2528 | return result; |
| 2529 | } |
| 2530 | } |
| 2531 | |
| 2532 | const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk, const unsigned char* end) { |
| 2533 | if(chunk >= end || end - chunk < 12) return end; /*too small to contain a chunk*/ |
no test coverage detected