mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Fix duplicate tIME chunk from png_write_png
Also add an example program, pngcp.c, which illustrates the problem when used to copy pngtest.png (the result is an invalid PNG because the tIME chunk is duplicated.) Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
@@ -2160,6 +2160,12 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Duplicate tIME chunks are invalid; this works round a bug in png_write_png
|
||||
* where it would write the tIME chunk once before and once after the IDAT.
|
||||
*/
|
||||
if (png_ptr->wrote_tIME)
|
||||
return;
|
||||
|
||||
png_save_uint_16(buf, mod_time->year);
|
||||
buf[2] = mod_time->month;
|
||||
buf[3] = mod_time->day;
|
||||
@@ -2168,6 +2174,7 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
buf[6] = mod_time->second;
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||
png_ptr->wrote_tIME = 1U;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user