ProfileData: Avoid UB when reading
authorJustin Bogner <mail@justinbogner.com>
Sat, 19 Apr 2014 00:33:12 +0000 (00:33 +0000)
committerJustin Bogner <mail@justinbogner.com>
Sat, 19 Apr 2014 00:33:12 +0000 (00:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206674 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/InstrProfReader.h

index 5b0c6257a631e8c80f076ce7b16b4d04511a1abf..18a7e43437a04bab4866a2e6d1fb0a1805a2efcf 100644 (file)
@@ -222,8 +222,9 @@ public:
   static std::pair<offset_type, offset_type>
   ReadKeyDataLength(const unsigned char *&D) {
     using namespace support;
-    return std::make_pair(endian::readNext<offset_type, little, unaligned>(D),
-                          endian::readNext<offset_type, little, unaligned>(D));
+    offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
+    offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
+    return std::make_pair(KeyLen, DataLen);
   }
 
   StringRef ReadKey(const unsigned char *D, unsigned N) {