4c1956
commit 832f50be6c9c010e46180d14126bbb81f35e808c
4c1956
Author: Florian Weimer <fweimer@redhat.com>
4c1956
Date:   Tue Jul 6 13:22:01 2021 +0200
4c1956
4c1956
    elf: Call free from base namespace on error in dl-libc.c [BZ #27646]
4c1956
    
4c1956
    In dlerror_run, free corresponds to the local malloc in the
4c1956
    namespace, but GLRO (dl_catch_error) uses the malloc from the base
4c1956
    namespace.  elf/tst-dlmopen-gethostbyname triggers this mismatch,
4c1956
    but it does not crash, presumably because of a fastbin deallocation.
4c1956
    
4c1956
    Fixes commit c2059edce20c124d1a99f1a94cc52e83b77a917a ("elf: Use
4c1956
    _dl_catch_error from base namespace in dl-libc.c [BZ #27646]") and
4c1956
    commit b2964eb1d9a6b8ab1250e8a881cf406182da5875 ("dlfcn: Failures
4c1956
    after dlmopen should not terminate process [BZ #24772]").
4c1956
4c1956
diff --git a/elf/dl-libc.c b/elf/dl-libc.c
4c1956
index 3a242d219756dac6..bb6e3378d546b234 100644
4c1956
--- a/elf/dl-libc.c
4c1956
+++ b/elf/dl-libc.c
4c1956
@@ -48,7 +48,7 @@ dlerror_run (void (*operate) (void *), void *args)
4c1956
 		?: last_errstring != NULL);
4c1956
 
4c1956
   if (result && malloced)
4c1956
-    free ((char *) last_errstring);
4c1956
+    GLRO (dl_error_free) ((char *) last_errstring);
4c1956
 
4c1956
   return result;
4c1956
 }