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