Avoid overflow when computing the size of an array

llvm-svn: 271031
This commit is contained in:
David Majnemer 2016-05-27 18:50:00 +00:00
parent 1d69da5279
commit 0e872f6475
1 changed files with 4 additions and 0 deletions

View File

@ -102,6 +102,10 @@ template <typename T, typename U> struct serialize_array_impl {
return std::error_code();
uint32_t Size = sizeof(T) * N;
if (Size / sizeof(T) != N)
return std::make_error_code(std::errc::illegal_byte_sequence);
if (Data.size() < Size)
return std::make_error_code(std::errc::illegal_byte_sequence);