diff options
author | Derek Schuff <dschuff@google.com> | 2015-05-21 19:40:19 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2015-05-21 19:40:19 +0000 |
commit | fcfd5ae82c93f9ff350fac4e7fb07d774139e1a5 (patch) | |
tree | f1b93053fc5cc40ead2dc95c2a81057f24ec968e /llvm/unittests/Support | |
parent | 286875874af11c4c5a1acd950b4dd82c556ce344 (diff) | |
download | bcm5719-llvm-fcfd5ae82c93f9ff350fac4e7fb07d774139e1a5.tar.gz bcm5719-llvm-fcfd5ae82c93f9ff350fac4e7fb07d774139e1a5.zip |
Fix StreamingMemoryObject to respect known object size.
The existing code for method StreamingMemoryObject.fetchToPos does not respect
the corresonding call to setKnownObjectSize(). As a result, it allows the
StreamingMemoryObject to read bytes past the object size.
This patch provides a test case, and code to fix the problem.
Patch by Karl Schimpf
Differential Revision: http://reviews.llvm.org/D8931
llvm-svn: 237939
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/StreamingMemoryObject.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/Support/StreamingMemoryObject.cpp b/llvm/unittests/Support/StreamingMemoryObject.cpp index 20136491ab8..c043efbb5e4 100644 --- a/llvm/unittests/Support/StreamingMemoryObject.cpp +++ b/llvm/unittests/Support/StreamingMemoryObject.cpp @@ -27,3 +27,12 @@ TEST(StreamingMemoryObject, Test) { StreamingMemoryObject O(DS); EXPECT_TRUE(O.isValidAddress(32 * 1024)); } + +TEST(StreamingMemoryObject, TestSetKnownObjectSize) { + auto *DS = new NullDataStreamer(); + StreamingMemoryObject O(DS); + uint8_t Buf[32]; + EXPECT_EQ((uint64_t) 16, O.readBytes(Buf, 16, 0)); + O.setKnownObjectSize(24); + EXPECT_EQ((uint64_t) 8, O.readBytes(Buf, 16, 16)); +} |