| 2432 | } |
| 2433 | |
| 2434 | unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk) |
| 2435 | { |
| 2436 | unsigned i; |
| 2437 | unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12; |
| 2438 | unsigned char *chunk_start, *new_buffer; |
| 2439 | size_t new_length = (*outlength) + total_chunk_length; |
| 2440 | if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/ |
| 2441 | |
| 2442 | new_buffer = (unsigned char*)lodepng_realloc(*out, new_length); |
| 2443 | if(!new_buffer) return 83; /*alloc fail*/ |
| 2444 | (*out) = new_buffer; |
| 2445 | (*outlength) = new_length; |
| 2446 | chunk_start = &(*out)[new_length - total_chunk_length]; |
| 2447 | |
| 2448 | for(i = 0; i < total_chunk_length; i++) chunk_start[i] = chunk[i]; |
| 2449 | |
| 2450 | return 0; |
| 2451 | } |
| 2452 | |
| 2453 | unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length, |
| 2454 | const char* type, const unsigned char* data) |
no test coverage detected