diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-20 10:52:11 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-20 10:52:11 +0000 |
commit | 46aed739555d2f821691b323d46de7ad7a75d5e7 (patch) | |
tree | 0577d6fc0b1c7248e0b691f22a7a86f6cb54c690 /unittests | |
parent | bee05dc8408d363335bb623a4f3349ff90639d35 (diff) | |
download | external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.zip external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.tar.gz external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.tar.bz2 |
DataExtractor: Fix integer truncation issues in LEB128 extraction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Support/DataExtractorTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/unittests/Support/DataExtractorTest.cpp b/unittests/Support/DataExtractorTest.cpp index 9813e46..ec8bd3d 100644 --- a/unittests/Support/DataExtractorTest.cpp +++ b/unittests/Support/DataExtractorTest.cpp @@ -16,6 +16,7 @@ namespace { const char numberData[] = "\x80\x90\xFF\xFF\x80\x00\x00\x00"; const char stringData[] = "hellohello\0hello"; const char leb128data[] = "\xA6\x49"; +const char bigleb128data[] = "\xAA\xA9\xFF\xAA\xFF\xAA\xFF\x4A"; TEST(DataExtractorTest, OffsetOverflow) { DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8); @@ -106,6 +107,14 @@ TEST(DataExtractorTest, LEB128) { offset = 0; EXPECT_EQ(-7002LL, DE.getSLEB128(&offset)); EXPECT_EQ(2U, offset); + + DataExtractor BDE(StringRef(bigleb128data, sizeof(bigleb128data)-1), false,8); + offset = 0; + EXPECT_EQ(42218325750568106ULL, BDE.getULEB128(&offset)); + EXPECT_EQ(8U, offset); + offset = 0; + EXPECT_EQ(-29839268287359830LL, BDE.getSLEB128(&offset)); + EXPECT_EQ(8U, offset); } } |