diff options
author | Christopher Ferris <cferris@google.com> | 2014-07-30 16:06:56 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2014-07-30 16:06:56 -0700 |
commit | e03e1eac0b7682884b6628df1305d34299680cb4 (patch) | |
tree | cd92bbdbf9b9ae464da7b46d25c01fe6bf5c1ad9 /tests/string_test.cpp | |
parent | 4ad5066e1de326e5db46df18eeade9a88bc11bec (diff) |
Fix memchr with a zero length.
The memchr implementation for 64 bit fails if these conditions occur:
- The buffer is 32 byte aligned.
- The buffer contains the character in the first byte.
- The count sent in is zero.
The function should return NULL, but it's not.
Bug: 16676625
Change-Id: Iab33cc7a8b79920350c72f054dff0e0a3cde69ce
Diffstat (limited to 'tests/string_test.cpp')
-rw-r--r-- | tests/string_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/string_test.cpp b/tests/string_test.cpp index bc2c05b40..73c94c602 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -763,6 +763,14 @@ TEST(string, memchr) { } } +TEST(string, memchr_zero) { + uint8_t* buffer; + ASSERT_EQ(0, posix_memalign(reinterpret_cast<void**>(&buffer), 64, 64)); + memset(buffer, 10, 64); + ASSERT_TRUE(NULL == memchr(buffer, 5, 0)); + ASSERT_TRUE(NULL == memchr(buffer, 10, 0)); +} + TEST(string, memrchr) { int seek_char = random() & 255; StringTestState<char> state(SMALL); |