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