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