From e8f58194c1b72fddba1dbcb86cd84b1a5f91f074 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Sat, 29 Dec 2018 18:52:14 +0100 Subject: executor: fix error handling of mmap() mmap() returns MAP_FAILED, which is (void *)(-1), in case of an error. This is different from NULL. --- executor/executor_bsd.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'executor/executor_bsd.h') diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h index b359d4781..3d22f91ed 100644 --- a/executor/executor_bsd.h +++ b/executor/executor_bsd.h @@ -86,13 +86,12 @@ static void cover_open(cover_t* cov) #else size_t mmap_alloc_size = kCoverSize * (is_kernel_64_bit ? 8 : 4); #endif - char* mmap_ptr = (char*)mmap(NULL, mmap_alloc_size, - PROT_READ | PROT_WRITE, - MAP_SHARED, cov->fd, 0); - if (mmap_ptr == NULL) + void* mmap_ptr = mmap(NULL, mmap_alloc_size, PROT_READ | PROT_WRITE, + MAP_SHARED, cov->fd, 0); + if (mmap_ptr == MAP_FAILED) fail("cover mmap failed"); - cov->data = mmap_ptr; - cov->data_end = mmap_ptr + mmap_alloc_size; + cov->data = (char*)mmap_ptr; + cov->data_end = cov->data + mmap_alloc_size; } static void cover_enable(cover_t* cov, bool collect_comps) -- cgit mrf-deployment