]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix potential ICAP null pointer dereference after rev.14082
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 16 Sep 2016 18:50:04 +0000 (06:50 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Sep 2016 18:50:04 +0000 (06:50 +1200)
Adjusted Adaptation::Icap::ModXact::finalizeLogInfo(), fixing possible
"Null pointer dereference".

 Detected by Coverity Scan. Issue 1372977

src/adaptation/icap/ModXact.cc

index 7e1158c42cc74d6f3f826b3ce83e786dddaee340..f8a57ae96fed879987a29459fb1a6a90e208dcc5 100644 (file)
@@ -1261,7 +1261,7 @@ void Adaptation::Icap::ModXact::finalizeLogInfo()
 {
     HttpRequest *adapted_request_ = NULL;
     HttpReply *adapted_reply_ = NULL;
-    HttpRequest *virgin_request_ = (virgin.cause ? virgin.cause : dynamic_cast<HttpRequest*>(virgin.header));
+    HttpRequest *virgin_request_ = const_cast<HttpRequest*>(&virginRequest());
     if (!(adapted_request_ = dynamic_cast<HttpRequest*>(adapted.header))) {
         // if the request was not adapted, use virgin request to simplify
         // the code further below
@@ -1269,7 +1269,7 @@ void Adaptation::Icap::ModXact::finalizeLogInfo()
         adapted_reply_ = dynamic_cast<HttpReply*>(adapted.header);
     }
 
-    Adaptation::Icap::History::Pointer h = (virgin_request_ ? virgin_request_->icapHistory() : NULL);
+    Adaptation::Icap::History::Pointer h = virgin_request_->icapHistory();
     Must(h != NULL); // ICAPXaction::maybeLog calls only if there is a log
     al.icp.opcode = ICP_INVALID;
     al.url = h->log_uri.termedBuf();