diff options
author | Cosmin Truta <ctruta@gmail.com> | 2019-04-07 19:50:12 -0400 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2019-04-07 19:50:12 -0400 |
commit | a627bd26a375f5c41d54f90a47c838157d1bec97 (patch) | |
tree | 87973f45366f695b4cd92a4c80faddcd7bb0ab7f | |
parent | 82ae623ec9bc3cb5c68aad22596a766e86d593b7 (diff) | |
download | libpng-a627bd26a375f5c41d54f90a47c838157d1bec97.tar.gz |
arm: Partially revert "Fix a memory leak in the riffled palette [...]"
The memory leak remains fixed, but the associated refactoring is
being reverted. Moving the initialization of the riffled palette
from png_do_read_transformations to png_init_palette_transformations
has caused a regression in some of the test programs.
Although png_init_palette_transformations is the proper place to
perform this initialization, and the test programs are technically
incorrect to fail, we are still undoing that refactoring for the
time being.
-rw-r--r-- | pngrtran.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/pngrtran.c b/pngrtran.c index d2bb82eeb..9a8fad9f4 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1161,20 +1161,7 @@ png_init_palette_transformations(png_structrp png_ptr) png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); } -#ifdef PNG_READ_EXPAND_SUPPORTED -#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE - /* Initialize the accelerated palette expansion, if applicable. */ - if ((png_ptr->transformations & PNG_EXPAND) != 0) - { - if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8)) - { - png_ptr->riffled_palette = (png_bytep)png_malloc(png_ptr, 256 * 4); - png_riffle_palette_neon(png_ptr); - } - } -#endif /* PNG_ARM_NEON_INTRINSICS_AVAILABLE */ - -#ifdef PNG_READ_BACKGROUND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) /* png_set_background handling - deals with the complexity of whether the * background color is in the file format or the screen format in the case * where an 'expand' will happen. @@ -1212,8 +1199,7 @@ png_init_palette_transformations(png_structrp png_ptr) #endif /* READ_INVERT_ALPHA */ } } /* background expand and (therefore) no alpha association. */ -#endif /* READ_BACKGROUND */ -#endif /* READ_EXPAND */ +#endif /* READ_EXPAND && READ_BACKGROUND */ } static void /* PRIVATE */ @@ -4785,6 +4771,18 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) { if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) { +#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE + if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8)) + { + if (png_ptr->riffled_palette == NULL) + { + /* Initialize the accelerated palette expansion. */ + png_ptr->riffled_palette = + (png_bytep)png_malloc(png_ptr, 256 * 4); + png_riffle_palette_neon(png_ptr); + } + } +#endif png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1, png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); } |