trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sor...@apache.org
Subject [trafficserver] 01/05: TS-4367: Failed clang-analyzer, memory leak in mgmt/api
Date Thu, 09 Feb 2017 17:42:42 GMT
This is an automated email from the ASF dual-hosted git repository.

sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 99c62ee4b4dbaa5921d83b47a27fc53090dfeb34
Author: Bryan Call <bcall@apache.org>
AuthorDate: Wed May 25 10:43:46 2016 -0700

    TS-4367: Failed clang-analyzer, memory leak in mgmt/api
    
    (cherry picked from commit 1cff52240584e5e6dccee63a02ab70ce61a961a2)
---
 mgmt/api/GenericParser.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mgmt/api/GenericParser.cc b/mgmt/api/GenericParser.cc
index 0eb5121..eb36872 100644
--- a/mgmt/api/GenericParser.cc
+++ b/mgmt/api/GenericParser.cc
@@ -354,12 +354,15 @@ Rule::cacheParse(char *rule, unsigned short minNumToken, unsigned short
maxNumTo
       if (insideQuote) {
         //              printf("enqueue\n");
         m_tokenList->enqueue(token);
+        token       = NULL; // transfered ownership of token to the token list
         insideQuote = false;
       } else {
         insideQuote = true;
       }
     }
   }
+
+  delete token;
   return m_tokenList;
 }
 
@@ -633,6 +636,7 @@ Rule::socksParse(char *rule)
           //          printf("!insideQuote: %s\n", subtoken);
           token->setValue(newStr);
           m_tokenList->enqueue(token);
+          token = NULL; // transfered ownership of token to the token list
         } else {
           //          printf("insideQuote: %s\n", subtoken);
           //          printf("%s 1\n", subtoken);
@@ -649,6 +653,7 @@ Rule::socksParse(char *rule)
         if (insideQuote) {
           //              printf("enqueue\n");
           m_tokenList->enqueue(token);
+          token       = NULL; // transfered ownership of token to the token list
           insideQuote = false;
         } else {
           insideQuote = true;
@@ -657,6 +662,7 @@ Rule::socksParse(char *rule)
     } /* end for loop */
   }
 
+  delete token;
   return m_tokenList;
 }
 
@@ -719,6 +725,7 @@ Rule::splitdnsParse(char *rule)
       if (!insideQuote) {
         token->setValue(newStr);
         m_tokenList->enqueue(token);
+        token = NULL; // transfered ownership of token to the token list
       } else {
         //          printf("%s 1\n", subtoken);
         token->appendValue(newStr);
@@ -734,6 +741,7 @@ Rule::splitdnsParse(char *rule)
       if (insideQuote) {
         //              printf("enqueue\n");
         m_tokenList->enqueue(token);
+        token       = NULL; // transfered ownership of token to the token list
         insideQuote = false;
       } else {
         insideQuote = true;
@@ -741,6 +749,7 @@ Rule::splitdnsParse(char *rule)
     }
   }
 
+  delete token;
   return m_tokenList;
   //  return cacheParse(rule, 2);
 }

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

Mime
View raw message