diff --git a/pngset.c b/pngset.c index 6e9c50aab..5c72dad32 100644 --- a/pngset.c +++ b/pngset.c @@ -955,10 +955,11 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) { /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, + info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); } + png_ptr->trans_alpha = info_ptr->trans_alpha; } if (trans_color != NULL)