aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/png
diff options
context:
space:
mode:
authorGravatar David G. Andersen <dga@google.com>2018-02-14 11:01:49 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-14 11:05:48 -0800
commitcedc74ee8ec418c39bac461e834636825163586a (patch)
tree815fb0d9ebc873490448c7c3acd2d503e3743390 /tensorflow/core/lib/png
parent4d90af18b92eb804bce2c334e718fddc691df28e (diff)
Call png_error if reading fails
Allows faster exit from reading corrupt PNG files. PiperOrigin-RevId: 185712829
Diffstat (limited to 'tensorflow/core/lib/png')
-rw-r--r--tensorflow/core/lib/png/png_io.cc5
1 files changed, 1 insertions, 4 deletions
diff --git a/tensorflow/core/lib/png/png_io.cc b/tensorflow/core/lib/png/png_io.cc
index 77a3414442..cba473927d 100644
--- a/tensorflow/core/lib/png/png_io.cc
+++ b/tensorflow/core/lib/png/png_io.cc
@@ -90,11 +90,8 @@ void WarningHandler(png_structp png_ptr, png_const_charp msg) {
void StringReader(png_structp png_ptr, png_bytep data, png_size_t length) {
DecodeContext* const ctx = bit_cast<DecodeContext*>(png_get_io_ptr(png_ptr));
if (static_cast<png_size_t>(ctx->data_left) < length) {
- if (!ctx->error_condition) {
- VLOG(1) << "PNG read decoding error";
- ctx->error_condition = true;
- }
memset(data, 0, length);
+ png_error(png_ptr, "More bytes requested to read than available");
} else {
memcpy(data, ctx->data, length);
ctx->data += length;