mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
__crt_aligned_alloc_offset(): fix ov_index for backing allocation address
Wrong value of ov_index resulted in magic check failure, and refuse to
free() the memory allocated with __crt_aligned_alloc_offset().
Then the TLS segments of exited threads leaked.
Reported and tested by: glebius
Fixes: c29ee08204
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
This commit is contained in:
parent
b7528b16c6
commit
03a7c36ddb
|
@ -188,7 +188,7 @@ __crt_aligned_alloc_offset(size_t align, size_t size, size_t offset)
|
|||
x += offset;
|
||||
ov = cp2op((void *)x);
|
||||
ov1.ov_magic = AMAGIC;
|
||||
ov1.ov_index = x - (uintptr_t)mem - sizeof(union overhead);
|
||||
ov1.ov_index = x - (uintptr_t)mem + sizeof(union overhead);
|
||||
memcpy(ov, &ov1, sizeof(ov1));
|
||||
return ((void *)x);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue