| 2456 | } |
| 2457 | |
| 2458 | unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk) |
| 2459 | { |
| 2460 | unsigned i; |
| 2461 | unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12; |
| 2462 | unsigned char *chunk_start, *new_buffer; |
| 2463 | size_t new_length = (*outlength) + total_chunk_length; |
| 2464 | if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/ |
| 2465 | |
| 2466 | new_buffer = (unsigned char*)lodepng_realloc(*out, new_length); |
| 2467 | if(!new_buffer) return 83; /*alloc fail*/ |
| 2468 | (*out) = new_buffer; |
| 2469 | (*outlength) = new_length; |
| 2470 | chunk_start = &(*out)[new_length - total_chunk_length]; |
| 2471 | |
| 2472 | for(i = 0; i < total_chunk_length; i++) chunk_start[i] = chunk[i]; |
| 2473 | |
| 2474 | return 0; |
| 2475 | } |
| 2476 | |
| 2477 | unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length, |
| 2478 | const char* type, const unsigned char* data) |
no test coverage detected