[29/59] libctf: pass the thunk down properly when wrapping qsort_r

Message ID 20200630233146.338613-30-nick.alcock@oracle.com
State New
Headers show
  • Deduplicating CTF linker
Related show

Commit Message

Alan Modra via Binutils June 30, 2020, 11:31 p.m.
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.

	ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing.
 libctf/ctf-decls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



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