You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2017/05/11 14:54:19 UTC

[trafficserver] branch master updated: Coverity CID #1022159 Resource leak

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

sorber 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  68ec3af   Coverity CID #1022159 Resource leak
68ec3af is described below

commit 68ec3af9b83a6b9ed82aaae4605cfcc83fdd6364
Author: Phil Sorber <so...@apache.org>
AuthorDate: Wed May 10 13:05:52 2017 -0600

    Coverity CID #1022159 Resource leak
---
 proxy/CoreUtils.cc | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/proxy/CoreUtils.cc b/proxy/CoreUtils.cc
index 1071138..9ba2fa0 100644
--- a/proxy/CoreUtils.cc
+++ b/proxy/CoreUtils.cc
@@ -488,11 +488,11 @@ CoreUtils::print_http_hdr(HTTPHdr *h, const char *name)
 int
 CoreUtils::load_http_hdr(HTTPHdr *core_hdr, HTTPHdr *live_hdr)
 {
+  char buf[sizeof(char) * sizeof(HdrHeap)];
   // Load HdrHeap chain
   HTTPHdr *http_hdr                 = core_hdr;
   HdrHeap *heap                     = (HdrHeap *)core_hdr->m_heap;
   HdrHeap *heap_ptr                 = (HdrHeap *)http_hdr->m_heap;
-  char *buf                         = (char *)ats_malloc(sizeof(char) * sizeof(HdrHeap));
   intptr_t ptr_heaps                = 0;
   intptr_t ptr_heap_size            = 0;
   intptr_t ptr_xl_size              = 2;
@@ -597,11 +597,7 @@ CoreUtils::load_http_hdr(HTTPHdr *core_hdr, HTTPHdr *live_hdr)
     char *free_start = (char *)(((HdrStrHeap *)str_hdr)->m_free_start);
     int nto_copy     = std::abs((char *)copy_start - free_start);
     ats_free(str_hdr);
-#if defined(__GNUC__)
     char rw_heap[sizeof(char) * nto_copy];
-#else
-    char *rw_heap   = (char *)ats_malloc(sizeof(char) * nto_copy);
-#endif
     if (read_from_core((intptr_t)copy_start, nto_copy, rw_heap) == -1) {
       printf("Cannot read from core\n");
       ::exit(0);
@@ -613,18 +609,11 @@ CoreUtils::load_http_hdr(HTTPHdr *core_hdr, HTTPHdr *live_hdr)
 
     str_size += nto_copy;
     str_heaps++;
-#if !defined(__GNUC__)
-    ats_free(rw_heap);
-#endif
   }
 
   for (i = 0; i < HDR_BUF_RONLY_HEAPS; i++) {
     if (heap->m_ronly_heap[i].m_heap_start != nullptr) {
-#if defined(__GNUC__)
       char ro_heap[sizeof(char) * heap->m_ronly_heap[i].m_heap_len];
-#else
-      char *ro_heap = (char *)ats_malloc(sizeof(char) * heap->m_ronly_heap[i].m_heap_len);
-#endif
       if (read_from_core((intptr_t)heap->m_ronly_heap[i].m_heap_start, heap->m_ronly_heap[i].m_heap_len, ro_heap) == -1) {
         printf("Cannot read from core\n");
         ::exit(0);
@@ -638,9 +627,6 @@ CoreUtils::load_http_hdr(HTTPHdr *core_hdr, HTTPHdr *live_hdr)
 
       str_heaps++;
       str_size += heap->m_ronly_heap[i].m_heap_len;
-#if !defined(__GNUC__)
-      ats_free(ro_heap);
-#endif
     }
   }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].