glibc/sysdeps/mach
Adhemerval Zanella c8e73a1492 stdlib: Fix qsort memory leak if callback throws (BZ 32058)
If the input buffer exceeds the stack auxiliary buffer, qsort will
malloc a temporary one to call mergesort.  Since C++ standard does
allow the callback comparison function to throw [1], the glibc
implementation can potentially leak memory.

The fixes uses a pthread_cleanup_combined_push and
pthread_cleanup_combined_pop, so it can work with and without
exception enables.  The qsort code path that calls malloc now
requires some extra setup and a call to __pthread_cleanup_push
anmd __pthread_cleanup_pop (which should be ok since they just
setup some buffer state).

Checked on x86_64-linux-gnu.

[1] https://timsong-cpp.github.io/cppwp/n4950/alg.c.library#4

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-04-02 18:01:55 +00:00
..
htl
hurd stdlib: Fix qsort memory leak if callback throws (BZ 32058) 2025-04-02 18:01:55 +00:00
i386
include
sys
x86
x86_64
Makefile
Subdirs
_strerror.c
adjtime.c
clock_gettime.c mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available 2025-03-25 01:10:10 +01:00
clock_nanosleep.c
configure mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available 2025-03-25 01:10:10 +01:00
configure.ac mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available 2025-03-25 01:10:10 +01:00
getloadavg.c
getpagesize.c
getsysstats.c
libc-lock.h
libmachuser.abilist
mach_rpc.h
mprotect.c
msync.c
munmap.c
pagecopy.h
readonly-area-fallback.c debug: Improve '%n' fortify detection (BZ 30932) 2025-03-21 15:46:48 -03:00
sched_yield.c
sleep.c
strerror_l.c
sysdep.h
thread_state.h
usleep.c
xpg-strerror.c