You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/05/22 15:06:35 UTC

[trafficserver] branch master updated: Fixed clang-analyzer issue with null pointer in BufferWriter

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

bcall 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 24f2594  Fixed clang-analyzer issue with null pointer in BufferWriter
24f2594 is described below

commit 24f259497b610258b1b8ccb9e1c47b000c4b9fb8
Author: Bryan Call <bc...@apache.org>
AuthorDate: Mon May 21 10:42:51 2018 -0700

    Fixed clang-analyzer issue with null pointer in BufferWriter
---
 lib/ts/BufferWriter.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/ts/BufferWriter.h b/lib/ts/BufferWriter.h
index 29e2522..3fcffc9 100644
--- a/lib/ts/BufferWriter.h
+++ b/lib/ts/BufferWriter.h
@@ -256,15 +256,13 @@ public:
   FixedBufferWriter &
   write(const void *data, size_t length) override
   {
-    size_t newSize = _attempted + length;
-#if defined(__clang_analyzer__)
-    ink_assert(_capacity == 0 || _buf != nullptr); // make clang-analyzer happy.
-#endif
+    const size_t newSize = _attempted + length;
 
     if (newSize <= _capacity) {
+      ink_assert(_buf != nullptr); // make clang-analyzer happy.
       std::memcpy(_buf + _attempted, data, length);
-
     } else if (_attempted < _capacity) {
+      ink_assert(_buf != nullptr); // make clang-analyzer happy.
       std::memcpy(_buf + _attempted, data, _capacity - _attempted);
     }
     _attempted = newSize;

-- 
To stop receiving notification emails like this one, please contact
bcall@apache.org.