--------------------- PatchSet 10285 Date: 2007/12/20 10:32:38 Author: adri Branch: s27_adri Tag: (none) Log: Fix a bug in the buffer size calculation, simplify the code somewhat. This fix brought to you in 30 minutes by Valgrind, saviour of the day. Members: libbuf/buf.c:1.1.2.6->1.1.2.7 Index: squid/libbuf/buf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/buf.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid/libbuf/buf.c 19 Dec 2007 07:56:22 -0000 1.1.2.6 +++ squid/libbuf/buf.c 20 Dec 2007 10:32:38 -0000 1.1.2.7 @@ -165,12 +165,11 @@ int buf_append(buf_t *b, const void *src, size_t len, buf_flags_t flags) { - if (b->size - b->len < len + 1) { - if (!buf_changesize(b, b->size + b->len + 1)) { - /* tsk! */ - return -1; - } + if (!buf_changesize(b, b->size + len + 1)) { + /* tsk! */ + return -1; } + assert(b->len + len < b->size); memcpy(b->b + b->len, src, len); b->len += len; #if 0