]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Tue, 10 Oct 2000 08:22:25 +0000 (08:22 +0000)
committerwessels <>
Tue, 10 Oct 2000 08:22:25 +0000 (08:22 +0000)
 - 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.

src/comm.cc

index 6dd269e9b6c0a10b9e45df352cf3963d0a40abcd..bc5bf60d667b4ade22a66dd68c8fc47a1598a92c 100644 (file)
@@ -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;