about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-28 13:11:20 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-28 13:55:42 +0530
commit4aedc25f55eda50010f2932fdb0a533db6f89f61 (patch)
treef2c47e5d461974da36b6540ee3957a1fcbb31d37 /stdlib
parentfb1621a88665ade96e7874046ed62b1cd2e7ff35 (diff)
downloadglibc-4aedc25f55eda50010f2932fdb0a533db6f89f61.tar.gz
glibc-4aedc25f55eda50010f2932fdb0a533db6f89f61.tar.xz
glibc-4aedc25f55eda50010f2932fdb0a533db6f89f61.zip
__cxa_thread_atexit_impl: Abort on allocation failure [BZ #18524]
Abort in the unlikely event that allocation fails when trying to
register a TLS destructor.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/cxa_thread_atexit_impl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c
index 577ed30931..fa6901a3a6 100644
--- a/stdlib/cxa_thread_atexit_impl.c
+++ b/stdlib/cxa_thread_atexit_impl.c
@@ -72,6 +72,7 @@
    is not very different from a case where __call_tls_dtors is called after
    _dl_close_worker on the DSO and hence is an accepted execution.  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <ldsodefs.h>
 
@@ -104,6 +105,9 @@ __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
 
   /* Prepend.  */
   struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
+  if (__glibc_unlikely (new == NULL))
+    __libc_fatal ("Fatal glibc error: failed to register TLS destructor: "
+		  "out of memory\n");
   new->func = func;
   new->obj = obj;
   new->next = tls_dtor_list;