Skip to content

Commit 5b4c886

Browse files
committed
Ignore error of os_munmap() when size equals 0
Fixes: #63 Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 7b28d9d commit 5b4c886

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/provider/provider_os_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ static umf_result_t os_free(void *provider, void *ptr, size_t size) {
337337

338338
errno = 0;
339339
int ret = os_munmap(ptr, size);
340-
if (ret) {
340+
// ignore error when size == 0
341+
if (ret && (size > 0)) {
341342
os_store_last_native_error(UMF_OS_RESULT_ERROR_FREE_FAILED, errno);
342343
if (os_config->traces) {
343344
perror("memory deallocation failed");

test/provider_os_memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ TEST_P(umfProviderTest, get_name) {
261261

262262
TEST_P(umfProviderTest, free_INVALID_POINTER) {
263263
umf_result_t umf_result =
264-
umfMemoryProviderFree(provider.get(), INVALID_PTR, 0);
264+
umfMemoryProviderFree(provider.get(), INVALID_PTR, page_plus_64);
265265
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC);
266266

267267
verify_last_native_error(provider.get(), UMF_OS_RESULT_ERROR_FREE_FAILED);

0 commit comments

Comments
 (0)