mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-04-19 22:10:19 +02:00
hold regions_lock in alloc_aligned
This commit is contained in:
parent
bec20a39cf
commit
a13a45a17d
1 changed files with 5 additions and 0 deletions
5
malloc.c
5
malloc.c
|
@ -790,10 +790,15 @@ static int alloc_aligned(void **memptr, size_t alignment, size_t size, size_t mi
|
|||
if (p == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(®ions_lock);
|
||||
if (regions_insert(p, size)) {
|
||||
pthread_mutex_unlock(®ions_lock);
|
||||
deallocate_pages(p, size, PAGE_SIZE);
|
||||
return ENOMEM;
|
||||
}
|
||||
pthread_mutex_unlock(®ions_lock);
|
||||
|
||||
*memptr = p;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue