]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix memory leak of lastAclData
authorNathan Hoad <nathan@getoffmalawn.com>
Fri, 11 Mar 2016 15:03:20 +0000 (04:03 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 11 Mar 2016 15:03:20 +0000 (04:03 +1300)
src/AccessLogEntry.cc
src/AccessLogEntry.h
src/external_acl.cc
src/format/Format.cc

index 488555d159a1e1fd7003c9db28d77f347bb00542..1bc599c1610e116a8c80100055f64fb903015060 100644 (file)
@@ -76,7 +76,6 @@ AccessLogEntry::~AccessLogEntry()
     HTTPMSGUNLOCK(adapted_request);
 
     safe_free(lastAclName);
-    safe_free(lastAclData);
 
     HTTPMSGUNLOCK(reply);
     HTTPMSGUNLOCK(request);
index 044c31089f0315d22d6b70110c0fb765c245d2cd..5968ab2f0f17b97eae8e8b1d768c45e1d344fd0e 100644 (file)
@@ -42,7 +42,6 @@ public:
     AccessLogEntry() :
         url(nullptr),
         lastAclName(nullptr),
-        lastAclData(nullptr),
         reply(nullptr),
         request(nullptr),
         adapted_request(nullptr)
@@ -207,7 +206,7 @@ public:
 #endif
 
     const char *lastAclName; ///< string for external_acl_type %ACL format code
-    const char *lastAclData; ///< string for external_acl_type %DATA format code
+    SBuf lastAclData; ///< string for external_acl_type %DATA format code
 
     HierarchyLogEntry hier;
     HttpReply *reply;
index 9671129988c90d4dfdae54d566eeb3a651390b39..9326989bcca36f3a50c5635ec4746a8de2e00b56 100644 (file)
@@ -742,7 +742,7 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data)
                 }
             }
 
-            ch->al->lastAclData = xstrdup(sb.c_str());
+            ch->al->lastAclData = sb;
         }
 
 #if USE_IDENT
index bfcc133fb07399e39c65efc11e15c7a9364273f8..c096aa4ee33b322ebdcbb030c98bb50d528ad4a5 100644 (file)
@@ -1381,7 +1381,8 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
             break;
 
         case LFT_EXT_ACL_DATA:
-            out = al->lastAclData;
+            if (!al->lastAclData.isEmpty())
+                out = al->lastAclData.c_str();
             break;
         }