From: robertc <> Date: Thu, 10 Jul 2003 15:37:56 +0000 (+0000) Subject: Summary: BUGFIX: httpStateData leaks. X-Git-Tag: SQUID_3_0_PRE1~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a91f4b1f26742bbbfbdcc0dab2231801db1847b;p=thirdparty%2Fsquid.git Summary: BUGFIX: httpStateData leaks. Keywords: CommRead's operator= was leaking cbdatareferences when assigning to an already extant object. Fixed. We could benefit by generalising the algorithm for refcounting classes further - to allow the reuse of RefCount's logic with classes owning CBDATA - like CommRead. --- diff --git a/src/CommRead.h b/src/CommRead.h index bf0d632242..5c93a377f8 100644 --- a/src/CommRead.h +++ b/src/CommRead.h @@ -1,6 +1,6 @@ /* - * $Id: CommRead.h,v 1.4 2003/07/06 13:43:40 hno Exp $ + * $Id: CommRead.h,v 1.5 2003/07/10 09:37:56 robertc Exp $ * * DEBUG: section 5 Comms * AUTHOR: Robert Collins @@ -67,24 +67,20 @@ public: ~CallBack() { - if (data) - cbdataReferenceDone(data); + replaceData (NULL); } CallBack &operator = (CallBack const & rhs) { handler = rhs.handler; - if (rhs.data) - data = cbdataReference (rhs.data); - else - data = NULL; + replaceData (rhs.data); return *this; } -bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rhs.data;} + bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rhs.data;} #if 0 // twould be nice - RBC 20030307 @@ -93,6 +89,20 @@ bool operator == (CallBack const &rhs) { return handler==rhs.handler && data==rh C *handler; void *data; + +private: + void replaceData(void *someData) + { + void *temp = NULL; + + if (someData) + temp = cbdataReference(someData); + + if (data) + cbdataReferenceDone(data); + + data = temp; + } }; #if 0