--------------------- PatchSet 1596 Date: 2005/08/24 21:26:17 Author: dwsquid Branch: squid3-icap Tag: (none) Log: Added a 'valid' flag to MemBuf for debugging memory corruption bugs Members: src/MemBuf.cc:1.6.8.3->1.6.8.4 src/MemBuf.cci:1.2->1.2.20.1 src/MemBuf.h:1.3.16.4->1.3.16.5 Index: squid3/src/MemBuf.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemBuf.cc,v retrieving revision 1.6.8.3 retrieving revision 1.6.8.4 diff -u -r1.6.8.3 -r1.6.8.4 --- squid3/src/MemBuf.cc 24 Aug 2005 19:13:07 -0000 1.6.8.3 +++ squid3/src/MemBuf.cc 24 Aug 2005 21:26:17 -0000 1.6.8.4 @@ -1,6 +1,6 @@ /* - * $Id: MemBuf.cc,v 1.6.8.3 2005/08/24 19:13:07 rousskov Exp $ + * $Id: MemBuf.cc,v 1.6.8.4 2005/08/24 21:26:17 dwsquid Exp $ * * DEBUG: section 59 auto-growing Memory Buffer with printf * AUTHOR: Alex Rousskov @@ -191,6 +191,7 @@ memBufIsNull(MemBuf * mb) { assert(mb); + //assert(mb->valid); if (!mb->buf && !mb->max_capacity && !mb->capacity && !mb->size) return 1; /* is null (not initialized) */ @@ -215,6 +216,7 @@ const mb_size_t cSize = contentSize(); assert(0 <= shiftSize && shiftSize <= cSize); assert(!stolen); /* not frozen */ + //assert(valid); if (shiftSize > 0) { if (shiftSize < cSize) xmemmove(buf, buf + shiftSize, cSize - shiftSize); @@ -228,6 +230,7 @@ assert(sz >= 0); assert(buf); assert(!stolen); /* not frozen */ + //assert(valid); if (sz > 0) { if (size + sz + 1 > capacity) Index: squid3/src/MemBuf.cci =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemBuf.cci,v retrieving revision 1.2 retrieving revision 1.2.20.1 diff -u -r1.2 -r1.2.20.1 --- squid3/src/MemBuf.cci 23 Jan 2003 03:14:41 -0000 1.2 +++ squid3/src/MemBuf.cci 24 Aug 2005 21:26:17 -0000 1.2.20.1 @@ -1,6 +1,6 @@ /* - * $Id: MemBuf.cci,v 1.2 2003/01/23 03:14:41 squidadm Exp $ + * $Id: MemBuf.cci,v 1.2.20.1 2005/08/24 21:26:17 dwsquid Exp $ * * DEBUG: section 59 auto-growing Memory Buffer with printf * AUTHOR: Robert Collins @@ -33,6 +33,11 @@ * */ -MemBuf::MemBuf() : buf (NULL), size (0), max_capacity (0), capacity(0), stolen(0) +MemBuf::MemBuf() : buf (NULL), size (0), max_capacity (0), capacity(0), stolen(0), valid(1) { } + +MemBuf::~MemBuf() +{ + valid = 0; +} Index: squid3/src/MemBuf.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemBuf.h,v retrieving revision 1.3.16.4 retrieving revision 1.3.16.5 diff -u -r1.3.16.4 -r1.3.16.5 --- squid3/src/MemBuf.h 24 Aug 2005 19:13:08 -0000 1.3.16.4 +++ squid3/src/MemBuf.h 24 Aug 2005 21:26:17 -0000 1.3.16.5 @@ -1,6 +1,6 @@ /* - * $Id: MemBuf.h,v 1.3.16.4 2005/08/24 19:13:08 rousskov Exp $ + * $Id: MemBuf.h,v 1.3.16.5 2005/08/24 21:26:17 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,6 +42,7 @@ public: _SQUID_INLINE_ MemBuf(); + _SQUID_INLINE_ ~MemBuf(); /* use methods instead of deprecated buf and size members */ @@ -80,6 +81,8 @@ unsigned stolen: 1; /* the buffer has been stolen for use by someone else */ +unsigned valid: + 1; /* to be used for debugging only! */ }; /* to initialize static variables (see also MemBufNull) */