--------------------- PatchSet 1527 Date: 2005/08/19 20:07:41 Author: rousskov Branch: squid3-icap Tag: (none) Log: - made sure that cleaning a buffer that has not been initialized yet does not lead to coredumps (this is similar to deleting a null pointer in C++). Members: src/MemBuf.cc:1.6.8.1->1.6.8.2 Index: squid3/src/MemBuf.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemBuf.cc,v retrieving revision 1.6.8.1 retrieving revision 1.6.8.2 diff -u -r1.6.8.1 -r1.6.8.2 --- squid3/src/MemBuf.cc 18 Aug 2005 05:14:33 -0000 1.6.8.1 +++ squid3/src/MemBuf.cc 19 Aug 2005 20:07:41 -0000 1.6.8.2 @@ -1,6 +1,6 @@ /* - * $Id: MemBuf.cc,v 1.6.8.1 2005/08/18 05:14:33 rousskov Exp $ + * $Id: MemBuf.cc,v 1.6.8.2 2005/08/19 20:07:41 rousskov Exp $ * * DEBUG: section 59 auto-growing Memory Buffer with printf * AUTHOR: Alex Rousskov @@ -156,12 +156,17 @@ memBufClean(MemBuf * mb) { assert(mb); - assert(mb->buf); - assert(!mb->stolen); /* not frozen */ - memFreeBuf(mb->capacity, mb->buf); - mb->buf = NULL; - mb->size = mb->capacity = mb->max_capacity = 0; + if (memBufIsNull(mb)) { + // nothing to do + } else { + assert(mb->buf); + assert(!mb->stolen); /* not frozen */ + + memFreeBuf(mb->capacity, mb->buf); + mb->buf = NULL; + mb->size = mb->capacity = mb->max_capacity = 0; + } } /* cleans the buffer without changing its capacity