This is an automated email from the ASF dual-hosted git repository.

masaori 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 1514bab  Fix SessionProtocolNameRegistry lookup
1514bab is described below

commit 1514babe826f2f44608c5cca7b150900e4592150
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Wed Mar 6 14:51:52 2019 +0900

    Fix SessionProtocolNameRegistry lookup
    
    Prior this change, SessionProtocolNameRegistry::indexFor() always returns 0.
    Because `spot` never reach to `m_names.end()`.
    This is introduced by 5ad8eec303b5f9c38da0de3775e0aadb7186fc38.
---
 lib/records/RecHttp.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index d20ab3a..0ad3378 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -751,8 +751,9 @@ SessionProtocolNameRegistry::toIndexConst(TextView name)
 int
 SessionProtocolNameRegistry::indexFor(TextView name) const
 {
-  auto spot = std::find(m_names.begin(), m_names.begin() + m_n, name);
-  if (spot != m_names.end()) {
+  const ts::TextView *end = m_names.begin() + m_n;
+  auto spot               = std::find(m_names.begin(), end, name);
+  if (spot != end) {
     return static_cast<int>(spot - m_names.begin());
   }
   return INVALID;

Reply via email to