From 92e1cd9b0ba9a8fa86e0346b121e159fb88f99bc Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 6 Oct 2012 16:56:35 -0400 Subject: [PATCH] don't crash if TLS library is loaded into process with no thread pointer --- src/ldso/dynlink.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index db7770b9..e944c8e1 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -533,6 +533,11 @@ static struct dso *load_library(const char *name) /* Add a shortname only if name arg was not an explicit pathname. */ if (pathname != name) p->shortname = strrchr(p->name, '/')+1; if (p->tls_image) { + if (!__pthread_self_init()) { + free(p); + munmap(map, map_len); + return 0; + } p->tls_id = ++tls_cnt; tls_align = MAXP2(tls_align, p->tls_align); tls_offset += p->tls_size + p->tls_align - 1; -- 2.25.1