From 49889a296e9e15077b36917329538e154789dd9f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 22 Jan 2017 21:26:45 +0000 Subject: coverity#1399029 silence Out-of-bounds read Change-Id: I025e416a6a162316d82cfbde9fbfcb0a45e888d5 --- sal/rtl/alloc_arena.cxx | 5 +++-- sal/rtl/alloc_cache.cxx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'sal') diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index 19bc4241b3b0..68dd29836ef5 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -217,8 +217,9 @@ rtl_arena_freelist_insert ( ) { rtl_arena_segment_type * head; - - head = &(arena->m_freelist_head[highbit(segment->m_size) - 1]); + const auto bit = highbit(segment->m_size); + assert(bit > 0); + head = &(arena->m_freelist_head[bit - 1]); QUEUE_INSERT_TAIL_NAMED(head, segment, f); arena->m_freelist_bitmap |= head->m_size; diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 29d20080c084..fd8a8c03205e 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -140,7 +140,6 @@ rtl_cache_hash_rescale ( rtl_cache_bufctl_type * next = curr->m_next; rtl_cache_bufctl_type ** head; - // coverity[negative_shift] head = &(cache->m_hash_table[RTL_CACHE_HASH_INDEX(cache, curr->m_addr)]); curr->m_next = (*head); (*head) = curr; @@ -212,8 +211,9 @@ rtl_cache_hash_remove ( if (!(cache->m_features & RTL_CACHE_FEATURE_RESCALE)) { sal_Size ave = nbuf >> cache->m_hash_shift; - // coverity[negative_shift] - sal_Size new_size = cache->m_hash_size << (highbit(ave) - 1); + const auto bit = highbit(ave); + assert(bit > 0); + sal_Size new_size = cache->m_hash_size << (bit - 1); cache->m_features |= RTL_CACHE_FEATURE_RESCALE; RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); -- cgit v1.2.3