Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding check for ptr cookie to be the same as segment cookie to catch… #687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/segment-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,15 @@ static bool mi_is_valid_pointer(const void* p) {
}

mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept {
return mi_is_valid_pointer(p);
if mi_likely(mi_is_valid_pointer(p)) {
return true;
}

// when unable to allocate aligned OS memory directly, pointer cookie is same as segment cookie
mi_segment_t* const segment = _mi_ptr_segment(p);
if (segment == NULL) return false;

return (_mi_ptr_cookie(segment) == segment->cookie);
}

/*
Expand Down