From c77de19ba92f394241ee8038b77b07544b5dd69f Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Mon, 4 Sep 2017 08:22:39 -0500 Subject: [PATCH] [libpng16] Revise contrib/oss-fuzz/libpng_read_fuzzer.cc --- contrib/oss-fuzz/libpng_read_fuzzer.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.cc b/contrib/oss-fuzz/libpng_read_fuzzer.cc index dd23563a5..2e8229d91 100644 --- a/contrib/oss-fuzz/libpng_read_fuzzer.cc +++ b/contrib/oss-fuzz/libpng_read_fuzzer.cc @@ -5,7 +5,7 @@ // Use of this source code is governed by a BSD-style license that may // be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE -// Last changed in libpng 1.6.33beta02 [September 3, 2017] +// Last changed in libpng 1.6.33beta02 [September 4, 2017] // The modifications in 2017 by Glenn Randers-Pehrson include // 1. addition of a PNG_CLEANUP macro, @@ -36,14 +36,12 @@ struct PngObjectHandler { BufState* buf_state = nullptr; ~PngObjectHandler() { - if (png_handler.row_ptr) - png_free(png_handler.png_ptr, png_handler.row_ptr); - if (png_handler.end_info_ptr) - png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr, - &png_handler.end_info_ptr); - else if (png_handler.info_ptr) - png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr, - nullptr); + if (row_ptr) + png_free(png_ptr, row_ptr); + if (end_info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr); + else if (info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); else png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); delete buf_state;