From b693308b33987972786ebb9fe8b8a713e8a28b14 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Sun, 12 Jan 2020 08:34:00 -0500 Subject: [PATCH] Unsigned int cannott be < 0 --- tensorflow/c/c_api.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc index dbb5c760f8e..97846af6408 100644 --- a/tensorflow/c/c_api.cc +++ b/tensorflow/c/c_api.cc @@ -1344,6 +1344,10 @@ void TF_OperationGetAttrString(TF_Operation* oper, const char* attr_name, InvalidArgument("Attribute '", attr_name, "' is not a string"); return; } + if (max_length == 0) { + InvalidArgument("Attribute '", max_length, "' is zero"); + return; + } const auto& s = attr->s(); std::memcpy(value, s.data(), std::min(s.length(), max_length)); }