| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 png_set_crc_action(png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); | 61 png_set_crc_action(png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); |
| 62 | 62 |
| 63 png_infop info_ptr = png_create_info_struct(png_ptr); | 63 png_infop info_ptr = png_create_info_struct(png_ptr); |
| 64 assert(info_ptr); | 64 assert(info_ptr); |
| 65 | 65 |
| 66 base::ScopedClosureRunner struct_deleter(base::Bind( | 66 base::ScopedClosureRunner struct_deleter(base::Bind( |
| 67 &png_destroy_read_struct, &png_ptr, &info_ptr, nullptr)); | 67 &png_destroy_read_struct, &png_ptr, &info_ptr, nullptr)); |
| 68 | 68 |
| 69 #ifdef PNG_FUZZ_PROGRESSIVE | 69 #ifdef PNG_FUZZ_PROGRESSIVE |
| 70 if (setjmp(png_jmpbuf(png_ptr))) { |
| 71 return 0; |
| 72 } |
| 73 |
| 70 png_set_progressive_read_fn(png_ptr, nullptr, nullptr, nullptr, nullptr); | 74 png_set_progressive_read_fn(png_ptr, nullptr, nullptr, nullptr, nullptr); |
| 71 png_process_data(png_ptr, info_ptr, const_cast<uint8_t*>(data), size); | 75 png_process_data(png_ptr, info_ptr, const_cast<uint8_t*>(data), size); |
| 72 #else | 76 #else |
| 73 // Setting up reading from buffer. | 77 // Setting up reading from buffer. |
| 74 std::unique_ptr<BufState> buf_state(new BufState()); | 78 std::unique_ptr<BufState> buf_state(new BufState()); |
| 75 buf_state->data = data + kPngHeaderSize; | 79 buf_state->data = data + kPngHeaderSize; |
| 76 buf_state->bytes_left = size - kPngHeaderSize; | 80 buf_state->bytes_left = size - kPngHeaderSize; |
| 77 png_set_read_fn(png_ptr, buf_state.get(), user_read_data); | 81 png_set_read_fn(png_ptr, buf_state.get(), user_read_data); |
| 78 png_set_sig_bytes(png_ptr, kPngHeaderSize); | 82 png_set_sig_bytes(png_ptr, kPngHeaderSize); |
| 79 | 83 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 116 |
| 113 for (int pass = 0; pass < passes; ++pass) { | 117 for (int pass = 0; pass < passes; ++pass) { |
| 114 for (png_uint_32 y = 0; y < height; ++y) { | 118 for (png_uint_32 y = 0; y < height; ++y) { |
| 115 png_read_row(png_ptr, static_cast<png_bytep>(row), NULL); | 119 png_read_row(png_ptr, static_cast<png_bytep>(row), NULL); |
| 116 } | 120 } |
| 117 } | 121 } |
| 118 #endif // PNG_FUZZ_PROGRESSIVE | 122 #endif // PNG_FUZZ_PROGRESSIVE |
| 119 | 123 |
| 120 return 0; | 124 return 0; |
| 121 } | 125 } |
| OLD | NEW |