Unverified Commit 36c5780a authored by Feng Xiao's avatar Feng Xiao Committed by GitHub

Merge pull request #4739 from asimshankar/tf-bytesize

Graceful failure in SerializeToArray().
parents b40cb4bc 2020e3d5
......@@ -316,7 +316,11 @@ bool MessageLite::SerializeToArray(void* data, int size) const {
}
bool MessageLite::SerializePartialToArray(void* data, int size) const {
int byte_size = ByteSizeLong();
size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size;
return false;
}
if (size < byte_size) return false;
uint8* start = reinterpret_cast<uint8*>(data);
uint8* end = SerializeWithCachedSizesToArray(start);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment