trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: Build: Fix array bounds error under -O3.
Date Tue, 19 Feb 2019 21:02:47 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 390ebe5  Build: Fix array bounds error under -O3.
390ebe5 is described below

commit 390ebe55712cce687a07427311a933fbaf073438
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Fri Feb 15 11:35:24 2019 -0600

    Build: Fix array bounds error under -O3.
---
 proxy/hdrs/HdrHeap.cc | 2 +-
 proxy/hdrs/HdrHeap.h  | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/proxy/hdrs/HdrHeap.cc b/proxy/hdrs/HdrHeap.cc
index cde0e9f..edbc578 100644
--- a/proxy/hdrs/HdrHeap.cc
+++ b/proxy/hdrs/HdrHeap.cc
@@ -962,7 +962,7 @@ HdrHeap::unmarshal(int buf_length, int obj_type, HdrHeapObjImpl **found_obj,
Ref
 inline bool
 HdrHeap::attach_str_heap(char const *h_start, int h_len, RefCountObj *h_ref_obj, int *index)
 {
-  if (static_cast<unsigned>(*index) >= HDR_BUF_RONLY_HEAPS) {
+  if (*index >= static_cast<int>(HDR_BUF_RONLY_HEAPS)) {
     return false;
   }
 
diff --git a/proxy/hdrs/HdrHeap.h b/proxy/hdrs/HdrHeap.h
index 6dd7deb..9811362 100644
--- a/proxy/hdrs/HdrHeap.h
+++ b/proxy/hdrs/HdrHeap.h
@@ -206,20 +206,20 @@ public:
   //  by a heap consolidation.  Does NOT lock for Multi-Threaed
   //  access!
   void
-  lock_ronly_str_heap(int i)
+  lock_ronly_str_heap(unsigned i)
   {
     m_ronly_heap[i].m_locked = true;
   }
 
   void
-  unlock_ronly_str_heap(int i)
+  unlock_ronly_str_heap(unsigned i)
   {
     m_ronly_heap[i].m_locked = false;
     // INKqa11238
     // Move slot i to the first available slot in m_ronly_heap[].
     // The move is necessary because the rest of the code assumes
     // heaps are always allocated in order.
-    for (int j = 0; j < i; j++) {
+    for (unsigned j = 0; j < i; j++) {
       if (m_ronly_heap[j].m_heap_start == nullptr) {
         // move slot i to slot j
         m_ronly_heap[j].m_ref_count_ptr = m_ronly_heap[i].m_ref_count_ptr;
@@ -230,6 +230,7 @@ public:
         m_ronly_heap[i].m_heap_start    = nullptr;
         m_ronly_heap[i].m_heap_len      = 0;
         m_ronly_heap[i].m_locked        = false;
+        break; // Did the move, time to go.
       }
     }
   }


Mime
View raw message