APE-Project/APE_Server — pull request #22 by jdtcdr (2012-01-22 03:34:53+00:00)
Title: Fix double free bug, Issue #14

Clear the buffer_in.data pointer in close_socket() so that a subsequent call to close the same socket again will not result in an attempt to free a buffer previously freed. On MacOS (10.7.2 at least) it is the case that
the same fd will be reported multiple times from one call to kevent(),
which means one call to the events_poll() on this platform. It seems like
this may be a bug with kevent; I don't see how it is being used improperly
to result in double events this way. In any case, what crashes aped
is the double free from calling close_socket() twice, and it is better
to clear the pointer anyway which avoids the double free and hence the crash.
Fixes Issue #14