Browse Source

fix int64 overflow, fix #1670

tags/20200413
nihui 6 years ago
parent
commit
88872f8ac3
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      tools/onnx/onnx2ncnn.cpp

+ 2
- 2
tools/onnx/onnx2ncnn.cpp View File

@@ -63,7 +63,7 @@ static std::vector<int> get_node_attr_ai(const onnx::NodeProto& node, const char
v.resize(attr.ints_size());
for (int j=0; j<attr.ints_size(); j++)
{
v[j] = attr.ints(j);
v[j] = std::max(std::min(attr.ints(j), (::google::protobuf::int64)INT_MAX), (::google::protobuf::int64)INT_MIN);
}

break;
@@ -102,7 +102,7 @@ static int get_node_attr_i(const onnx::NodeProto& node, const char* key, int def
const onnx::AttributeProto& attr = node.attribute(i);
if (attr.name() == key)
{
return attr.i();
return std::max(std::min(attr.i(), (::google::protobuf::int64)INT_MAX), (::google::protobuf::int64)INT_MIN);
}
}



Loading…
Cancel
Save