提交 dac70ad4 编写于 作者: X xjqbest

fix bug of num > INT_MAX

上级 74471397
...@@ -531,7 +531,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -531,7 +531,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
char* endptr = const_cast<char*>(str); char* endptr = const_cast<char*>(str);
int len = line.length(); int len = line.length();
for (size_t i = 0; i < all_slots_.size(); ++i) { for (size_t i = 0; i < all_slots_.size(); ++i) {
int num = strtol(endptr, &endptr, 10); long num = strtol(endptr, &endptr, 10);
if (num < 0) { if (num < 0) {
VLOG(0) << "error: the number of ids is a negative number: " << num; VLOG(0) << "error: the number of ids is a negative number: " << num;
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
...@@ -546,7 +546,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -546,7 +546,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
return false; return false;
} else if (errno == ERANGE || (unsigned int)num > INT_MAX) { } else if (errno == ERANGE) {
VLOG(0) << "error: the number of ids greater than INT_MAX"; VLOG(0) << "error: the number of ids greater than INT_MAX";
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册