summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/utils/JenkinsHash.h3
-rw-r--r--libutils/JenkinsHash.cpp10
-rw-r--r--libutils/VectorImpl.cpp4
3 files changed, 17 insertions, 0 deletions
diff --git a/include/utils/JenkinsHash.h b/include/utils/JenkinsHash.h
index 7da5dbd6a..027c10c7e 100644
--- a/include/utils/JenkinsHash.h
+++ b/include/utils/JenkinsHash.h
@@ -29,6 +29,9 @@ namespace android {
29/* The Jenkins hash of a sequence of 32 bit words A, B, C is: 29/* The Jenkins hash of a sequence of 32 bit words A, B, C is:
30 * Whiten(Mix(Mix(Mix(0, A), B), C)) */ 30 * Whiten(Mix(Mix(Mix(0, A), B), C)) */
31 31
32#ifdef __clang__
33__attribute__((no_sanitize("integer")))
34#endif
32inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) { 35inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) {
33 hash += data; 36 hash += data;
34 hash += (hash << 10); 37 hash += (hash << 10);
diff --git a/libutils/JenkinsHash.cpp b/libutils/JenkinsHash.cpp
index 52c9bb7df..ff5d252a4 100644
--- a/libutils/JenkinsHash.cpp
+++ b/libutils/JenkinsHash.cpp
@@ -19,10 +19,14 @@
19 * should still be quite good. 19 * should still be quite good.
20 **/ 20 **/
21 21
22#include <stdlib.h>
22#include <utils/JenkinsHash.h> 23#include <utils/JenkinsHash.h>
23 24
24namespace android { 25namespace android {
25 26
27#ifdef __clang__
28__attribute__((no_sanitize("integer")))
29#endif
26hash_t JenkinsHashWhiten(uint32_t hash) { 30hash_t JenkinsHashWhiten(uint32_t hash) {
27 hash += (hash << 3); 31 hash += (hash << 3);
28 hash ^= (hash >> 11); 32 hash ^= (hash >> 11);
@@ -31,6 +35,9 @@ hash_t JenkinsHashWhiten(uint32_t hash) {
31} 35}
32 36
33uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) { 37uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
38 if (size > UINT32_MAX) {
39 abort();
40 }
34 hash = JenkinsHashMix(hash, (uint32_t)size); 41 hash = JenkinsHashMix(hash, (uint32_t)size);
35 size_t i; 42 size_t i;
36 for (i = 0; i < (size & -4); i += 4) { 43 for (i = 0; i < (size & -4); i += 4) {
@@ -47,6 +54,9 @@ uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
47} 54}
48 55
49uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) { 56uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) {
57 if (size > UINT32_MAX) {
58 abort();
59 }
50 hash = JenkinsHashMix(hash, (uint32_t)size); 60 hash = JenkinsHashMix(hash, (uint32_t)size);
51 size_t i; 61 size_t i;
52 for (i = 0; i < (size & -2); i += 2) { 62 for (i = 0; i < (size & -2); i += 2) {
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index 30ca6635e..bdb54b14a 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -551,6 +551,10 @@ size_t SortedVectorImpl::orderOf(const void* item) const
551 551
552ssize_t SortedVectorImpl::_indexOrderOf(const void* item, size_t* order) const 552ssize_t SortedVectorImpl::_indexOrderOf(const void* item, size_t* order) const
553{ 553{
554 if (order) *order = 0;
555 if (isEmpty()) {
556 return NAME_NOT_FOUND;
557 }
554 // binary search 558 // binary search
555 ssize_t err = NAME_NOT_FOUND; 559 ssize_t err = NAME_NOT_FOUND;
556 ssize_t l = 0; 560 ssize_t l = 0;