| 2491 | } |
| 2492 | |
| 2493 | unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk) |
| 2494 | { |
| 2495 | unsigned i; |
| 2496 | unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12; |
| 2497 | unsigned char *chunk_start, *new_buffer; |
| 2498 | size_t new_length = (*outlength) + total_chunk_length; |
| 2499 | if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/ |
| 2500 | |
| 2501 | new_buffer = (unsigned char*)lodepng_realloc(*out, new_length); |
| 2502 | if(!new_buffer) return 83; /*alloc fail*/ |
| 2503 | (*out) = new_buffer; |
| 2504 | (*outlength) = new_length; |
| 2505 | chunk_start = &(*out)[new_length - total_chunk_length]; |
| 2506 | |
| 2507 | for(i = 0; i != total_chunk_length; ++i) chunk_start[i] = chunk[i]; |
| 2508 | |
| 2509 | return 0; |
| 2510 | } |
| 2511 | |
| 2512 | unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length, |
| 2513 | const char* type, const unsigned char* data) |
no test coverage detected