From: Amos Jeffries Date: Fri, 6 Feb 2015 19:45:02 +0000 (-0800) Subject: Fix potential NULL dereference X-Git-Tag: merge-candidate-3-v1~280 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8a2338fd9bc8930fa3c5ce72ba2beb493642629;p=thirdparty%2Fsquid.git Fix potential NULL dereference Logging can potentially happen when there is no client request underway. Detected by Coverity Scan. Issue 434122 --- diff --git a/src/client_side.cc b/src/client_side.cc index f075afd95b..d6a010cb27 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 ¬es = 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 ¬es = SyncNotes(*al, *request); + notes.add((*i)->key.termedBuf(), value); + debugs(33, 3, (*i)->key.termedBuf() << " " << value); + } } }