pool: fix memory leak

Due to pointer size mishandling, the pool code could consider a
block of memory inside the 'preallocated' block. It would then not
free the block.
pull/1851/head
Victor Julien 9 years ago
parent b93a302a5b
commit 4086938f1e

@ -147,6 +147,7 @@
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h errno.h fcntl.h inttypes.h])
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([limits.h netdb.h netinet/in.h poll.h sched.h signal.h])

@ -49,6 +49,10 @@
#include <stdio.h>
#endif
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_STDINT_h
#include <stdint.h>
#endif

@ -54,10 +54,10 @@ static int PoolMemset(void *pitem, void *initdata)
/**
* \brief Check if data is preallocated
* \retval 0 or -1 if not inside */
* \retval 0 if not inside the prealloc'd block, 1 if inside */
static int PoolDataPreAllocated(Pool *p, void *data)
{
int delta = data - p->data_buffer;
ptrdiff_t delta = data - p->data_buffer;
if ((delta < 0) || (delta > p->data_buffer_size)) {
return 0;
}

Loading…
Cancel
Save