/* Align to the maximum size used by the swap optimization. */ _Alignas (uint64_t) char tmp[QSORT_STACK_SIZE]; size_t total_size = total_elems * size; char *buf; if (size > INDIRECT_SORT_SIZE_THRES) total_size = 2 * total_elems * sizeof (void *) + size; if (total_size < sizeof buf) buf = tmp; else { /* allocate buf on heap ... */ } Here "sizeof buf" is the size of a pointer, but (obviously?) we want QSORT_STACK_SIZE here, i.e. "sizeof tmp".
Fixed by https://sourceware.org/git?p=glibc.git;a=commit;h=dfa3394a605c8f6f25e4f827789bc89eca1d206c