Unsigned int cannott be < 0

This commit is contained in:
Gaurav Singh 2020-01-12 08:34:00 -05:00
parent bc15deffb8
commit b693308b33

View File

@ -1344,6 +1344,10 @@ void TF_OperationGetAttrString(TF_Operation* oper, const char* attr_name,
InvalidArgument("Attribute '", attr_name, "' is not a string"); InvalidArgument("Attribute '", attr_name, "' is not a string");
return; return;
} }
if (max_length == 0) {
InvalidArgument("Attribute '", max_length, "' is zero");
return;
}
const auto& s = attr->s(); const auto& s = attr->s();
std::memcpy(value, s.data(), std::min<size_t>(s.length(), max_length)); std::memcpy(value, s.data(), std::min<size_t>(s.length(), max_length));
} }