]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix potential NULL dereference
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 6 Feb 2015 19:45:02 +0000 (11:45 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 6 Feb 2015 19:45:02 +0000 (11:45 -0800)
Logging can potentially happen when there is no client
request underway.

  Detected by Coverity Scan. Issue 434122

src/client_side.cc

index f075afd95bc66a4df443fd92d226fbbc6dd315db..d6a010cb2760626ce594ace400c5648190ca0850 100644 (file)
@@ -623,15 +623,16 @@ ClientHttpRequest::logRequest()
 
 #endif
 
-    /*Add notes*/
-    // The al->notes and request->notes must point to the same object.
-    (void)SyncNotes(*al, *request);
-    typedef Notes::iterator ACAMLI;
-    for (ACAMLI i = Config.notes.begin(); i != Config.notes.end(); ++i) {
-        if (const char *value = (*i)->match(request, al->reply, NULL)) {
-            NotePairs &notes = SyncNotes(*al, *request);
-            notes.add((*i)->key.termedBuf(), value);
-            debugs(33, 3, HERE << (*i)->key.termedBuf() << " " << value);
+    /* Add notes (if we have a request to annotate) */
+    if (request) {
+        // The al->notes and request->notes must point to the same object.
+        (void)SyncNotes(*al, *request);
+        for (auto i = Config.notes.begin(); i != Config.notes.end(); ++i) {
+            if (const char *value = (*i)->match(request, al->reply, NULL)) {
+                NotePairs &notes = SyncNotes(*al, *request);
+                notes.add((*i)->key.termedBuf(), value);
+                debugs(33, 3, (*i)->key.termedBuf() << " " << value);
+            }
         }
     }