From Bill Parker:

Add error handler to munmap() failure in emem.c

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7850

svn path=/trunk/; revision=45915
This commit is contained in:
Anders Broman 2012-11-05 09:04:53 +00:00
parent 217c746d83
commit f5226f1310
1 changed files with 9 additions and 1 deletions

View File

@ -367,6 +367,8 @@ emem_init(void)
#elif defined(USE_GUARD_PAGES)
pagesize = sysconf(_SC_PAGESIZE);
if (pagesize == -1)
fprintf(stderr, "Warning: call to sysconf() for _SC_PAGESIZE has failed...\n");
#ifdef NEED_DEV_ZERO
dev_zero_fd = ws_open("/dev/zero", O_RDWR);
g_assert(dev_zero_fd != -1);
@ -680,7 +682,13 @@ emem_destroy_chunk(emem_chunk_t *npc)
#if defined (_WIN32)
VirtualFree(npc->buf, 0, MEM_RELEASE);
#elif defined(USE_GUARD_PAGES)
munmap(npc->buf, npc->amount_free_init);
/* we cannot recover from a munmap() failure, but we */
/* can print an informative error message to stderr */
if (munmap(npc->buf, npc->amount_free_init) != 0)
fprintf(stderr, "Warning: Unable to unmap memory chunk which has address %p and size %u\n",
npc->buf, npc->amount_free_init);
#else
g_free(npc->buf);
#endif