From: wessels <> Date: Tue, 10 Oct 2000 08:22:25 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1816 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=729dd65c7da6c691c55346ab44d03ca229200709;p=thirdparty%2Fsquid.git DW: - I get coredumps in free() with CommWriteStateCallbackAndFree sometime. Not sure if there is a bug here, but it seems like that code could lead to double-freeing the buffer. This change makes it safer by NULL-ing the free_func before freeing the buffer. --- diff --git a/src/comm.cc b/src/comm.cc index 6dd269e9b6..bc5bf60d66 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.308 2000/10/05 12:30:10 adrian Exp $ + * $Id: comm.cc,v 1.309 2000/10/10 02:22:25 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -84,8 +84,11 @@ CommWriteStateCallbackAndFree(int fd, int code) if (CommWriteState == NULL) return; if (CommWriteState->free_func) { - CommWriteState->free_func(CommWriteState->buf); + FREE *free_func = CommWriteState->free_func; + void *free_buf = CommWriteState->buf; + CommWriteState->free_func = NULL; CommWriteState->buf = NULL; + free_func(free_buf); } callback = CommWriteState->handler; data = CommWriteState->handler_data;