From 368bb1b241a9af627b6f72696fce862f920f7acc Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 22 Nov 2015 20:34:00 -0800 Subject: [PATCH] Fix certain minimal config builds The removal of png_struct::row_buffer and png_struct::row_format from write builds configured without filter or transform support (respectively) wasn't complete; some of the png.c and pngwrite.c cleanup code needed to handle the potentially removed members. Signed-off-by: John Bowler --- png.c | 8 +++++--- pngwrite.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/png.c b/png.c index 715488e53..2503e6c8e 100644 --- a/png.c +++ b/png.c @@ -2448,10 +2448,12 @@ png_copy_row(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp, * little endian; bits to copy in the bottom of 's'. Make 'remaining' * into a mask of the bits to *preserve* in dp. */ - if ((png_ptr->row_format & PNG_FORMAT_FLAG_SWAPPED) == 0U) - remaining = 0xffU >> remaining; +# ifdef PNG_TRANSFORM_MECH_SUPPORTED + if ((png_ptr->row_format & PNG_FORMAT_FLAG_SWAPPED) == 0U) + remaining = 0xffU >> remaining; - else + else +# endif /* TRANSFORM_MECH */ remaining = 0xffU << remaining; /* remaining is now the bits to *keep* from the destination byte, if diff --git a/pngwrite.c b/pngwrite.c index dce3d89e5..bf06b89fd 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1147,8 +1147,10 @@ png_write_destroy(png_structrp png_ptr) /* Free our memory. png_free checks NULL for us. */ png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); +#ifdef PNG_WRITE_FILTER_SUPPORTED png_free(png_ptr, png_ptr->row_buffer); png_ptr->row_buffer = NULL; +#endif /* WRITE_FILTER */ #ifdef PNG_TRANSFORM_MECH_SUPPORTED png_transform_free(png_ptr, &png_ptr->transform_list); #endif