summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-27 18:50:00 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-27 18:50:00 +0000
commit0e872f6475c389de95dd48eb17a55117db48095e (patch)
treeea2d3e000edf879e9d1482169bacedd396d3dd70
parent1d69da52798dc6fb274d733fa1656ef365e2b5b7 (diff)
downloadbcm5719-llvm-0e872f6475c389de95dd48eb17a55117db48095e.tar.gz
bcm5719-llvm-0e872f6475c389de95dd48eb17a55117db48095e.zip
Avoid overflow when computing the size of an array
llvm-svn: 271031
-rw-r--r--llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h b/llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h
index 0a11536e0de..ef44f9d9418 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h
@@ -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);
OpenPOWER on IntegriCloud