You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/09/05 13:28:30 UTC
[trafficserver] 01/03: coverity 1196489: Read from pointer after
free
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 926eff96b343054c4c7bf58a3554060dfdfaf39f
Author: Bryan Call <bc...@apache.org>
AuthorDate: Sun Jul 23 13:52:15 2017 +0200
coverity 1196489: Read from pointer after free
(cherry picked from commit e8ae4d87dd252e153b22072ecf74b207d7b76857)
---
proxy/logging/LogHost.cc | 20 ++++++++++----------
proxy/logging/LogHost.h | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index 68eeff7..3a9659b 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -247,20 +247,20 @@ LogHost::disconnect()
// preprocess the given buffer data before sent to target host
// and try to delete it when its reference become zero.
//
-int
+bool
LogHost::preproc_and_try_delete(LogBuffer *lb)
{
- int ret = -1;
-
if (lb == nullptr) {
Note("Cannot write LogBuffer to LogHost %s; LogBuffer is NULL", name());
- return -1;
+ return false;
}
+
LogBufferHeader *buffer_header = lb->header();
if (buffer_header == nullptr) {
Note("Cannot write LogBuffer to LogHost %s; LogBufferHeader is NULL", name());
goto done;
}
+
if (buffer_header->entry_count == 0) {
// no bytes to write
goto done;
@@ -277,11 +277,11 @@ LogHost::preproc_and_try_delete(LogBuffer *lb)
goto done;
}
- return 0;
+ return true;
done:
LogBuffer::destroy(lb);
- return ret;
+ return false;
}
//
@@ -405,7 +405,7 @@ LogHostList::clear()
int
LogHostList::preproc_and_try_delete(LogBuffer *lb)
{
- int ret;
+ int success = false;
unsigned nr_host, nr;
bool need_orphan = true;
LogHost *available_host = nullptr;
@@ -421,9 +421,9 @@ LogHostList::preproc_and_try_delete(LogBuffer *lb)
do {
ink_atomic_increment(&lb->m_references, 1);
- ret = lh->preproc_and_try_delete(lb);
- need_orphan = need_orphan && (ret < 0);
- } while (ret < 0 && (lh = lh->failover_link.next));
+ success = lh->preproc_and_try_delete(lb);
+ need_orphan = need_orphan && (success == false);
+ } while (lb && (success == false) && (lh = lh->failover_link.next));
nr--;
}
diff --git a/proxy/logging/LogHost.h b/proxy/logging/LogHost.h
index 8546f88..8eb1933 100644
--- a/proxy/logging/LogHost.h
+++ b/proxy/logging/LogHost.h
@@ -52,7 +52,7 @@ public:
// preprocess the given buffer data before sent to target host
// and try to delete it when its reference become zero.
//
- int preproc_and_try_delete(LogBuffer *lb);
+ bool preproc_and_try_delete(LogBuffer *lb);
//
// write the given buffer data to orphan file and