forked from mindspore-Ecosystem/mindspore
Fix the problems from self codecheck
This commit is contained in:
parent
a693757c49
commit
5ebf2bbf63
|
@ -1126,6 +1126,10 @@ bool DebugServices::CheckOpOverflow(std::string node_name_to_find, unsigned int
|
|||
const size_t buf_size = 256;
|
||||
buffer.resize(buf_size);
|
||||
(void)infile.read(buffer.data(), buf_size);
|
||||
if (infile.gcount() != buf_size) {
|
||||
MS_LOG(ERROR) << "The file: " << file_path << "may be damaged!";
|
||||
continue;
|
||||
}
|
||||
const uint8_t stream_id_offset = 16;
|
||||
const uint8_t task_id_offset = 24;
|
||||
// The stream_id and task_id in the dump file are 8 byte fields for extensibility purpose, but only hold 4
|
||||
|
|
|
@ -866,7 +866,7 @@ std::list<TensorProto> Debugger::LoadTensors(const ProtoVector<TensorProto> &ten
|
|||
// items in ret_name will be in the same order with tensors if found
|
||||
debug_services_->ReadNodesTensors(name, &ret_name, &data_ptr, &data_size, &dtype, &shape);
|
||||
std::list<TensorProto> tensor_list;
|
||||
unsigned int result_index = 0;
|
||||
size_t result_index = 0;
|
||||
|
||||
for (auto tensor : tensors) {
|
||||
ssize_t size_iter = 0;
|
||||
|
@ -897,6 +897,9 @@ std::list<TensorProto> Debugger::LoadTensors(const ProtoVector<TensorProto> &ten
|
|||
}
|
||||
// add tensor to result list and increment result_index to check next item in ret_name
|
||||
tensor_list.push_back(tensor_item);
|
||||
if (size_iter > INT_MAX - g_chunk_size) {
|
||||
MS_EXCEPTION(ValueError) << size_iter << " + " << g_chunk_size << " would lead to integer overflow!";
|
||||
}
|
||||
size_iter += g_chunk_size;
|
||||
}
|
||||
result_index++;
|
||||
|
|
|
@ -83,6 +83,9 @@ std::vector<std::string> GrpcClient::ChunkString(std::string str, int graph_size
|
|||
MS_LOG(EXCEPTION) << "memcpy_s failed. errorno is: " << err;
|
||||
}
|
||||
buf.push_back(buffer);
|
||||
if (size_iter > INT_MAX - l_chunk_size) {
|
||||
MS_EXCEPTION(ValueError) << size_iter << " + " << l_chunk_size << "would lead to integer overflow!";
|
||||
}
|
||||
size_iter += l_chunk_size;
|
||||
}
|
||||
return buf;
|
||||
|
|
Loading…
Reference in New Issue