Skip to content

Commit 0740851

Browse files
Fix a very old type confusion error.
PiperOrigin-RevId: 588138163
1 parent b8057c5 commit 0740851

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tensorflow/core/lib/png/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ cc_library(
1515
name = "png_io",
1616
srcs = ["png_io.cc"],
1717
hdrs = ["png_io.h"],
18+
features = ["-layering_check"],
1819
deps = [
1920
"//tensorflow/core/platform:byte_order",
2021
"//tensorflow/core/platform:logging",
2122
"//tensorflow/core/platform:png",
2223
"//tensorflow/core/platform:stringpiece",
2324
"//tensorflow/core/platform:types",
2425
"@com_google_absl//absl/base",
26+
"@png",
2527
"@zlib",
2628
],
2729
)

tensorflow/core/lib/png/png_io.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ limitations under the License.
2525
// provokes a compile error. We instead let png.h include what is needed.
2626

2727
#include "absl/base/casts.h"
28+
#include "png.h" // from @png
2829
#include "tensorflow/core/lib/png/png_io.h"
2930
#include "tensorflow/core/platform/byte_order.h"
3031
#include "tensorflow/core/platform/logging.h"
@@ -77,7 +78,7 @@ static void Convert8to16(const uint8* p8, int num_comps, int p8_row_bytes,
7778

7879
void ErrorHandler(png_structp png_ptr, png_const_charp msg) {
7980
DecodeContext* const ctx =
80-
absl::bit_cast<DecodeContext*>(png_get_io_ptr(png_ptr));
81+
absl::bit_cast<DecodeContext*>(png_get_error_ptr(png_ptr));
8182
ctx->error_condition = true;
8283
// To prevent log spam, errors are logged as VLOG(1) instead of ERROR.
8384
VLOG(1) << "PNG error: " << msg;
@@ -354,8 +355,9 @@ bool WriteImageToBuffer(
354355

355356
png_string->resize(0);
356357
png_infop info_ptr = nullptr;
357-
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr,
358-
ErrorHandler, WarningHandler);
358+
DecodeContext decode_context;
359+
png_structp png_ptr = png_create_write_struct(
360+
PNG_LIBPNG_VER_STRING, &decode_context, ErrorHandler, WarningHandler);
359361
if (png_ptr == nullptr) return false;
360362
if (setjmp(png_jmpbuf(png_ptr))) {
361363
png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr : nullptr);

0 commit comments

Comments
 (0)