From: Nick Alcock Date: Tue, 30 Jun 2020 17:02:28 +0000 (+0100) Subject: libctf: pass the thunk down properly when wrapping qsort_r X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67d4cc671b7b3c49f748546a510005333fcbc465;p=binutils-gdb.git libctf: pass the thunk down properly when wrapping qsort_r When wrapping qsort_r on a system like FreeBSD on which the compar argument comes first, we wrap the passed arg in a thunk so we can pass down both the caller-supplied comparator function and its argument. We should pass the *argument* down to the comparator, not the thunk, which is basically random nonsense on the stack from the point of view of the caller of qsort_r. libctf/ ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing. --- diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 779f7b1cc87..4a10f63d00c 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,7 @@ +2020-07-22 Nick Alcock + + ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing. + 2020-07-22 Nick Alcock * ctf-impl.h (ctf_next_hkv_t): New, kv-pairs passed to diff --git a/libctf/ctf-decls.h b/libctf/ctf-decls.h index 51041c592f4..c47a72e722f 100644 --- a/libctf/ctf-decls.h +++ b/libctf/ctf-decls.h @@ -46,7 +46,7 @@ ctf_qsort_compar_thunk (void *arg, const void *a, const void *b) { struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg; - return qsort_arg->compar (a, b, arg); + return qsort_arg->compar (a, b, qsort_arg->arg); } static inline void