summaryrefslogtreecommitdiff
path: root/src/ldso
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-10-06 16:56:35 -0400
committerRich Felker <dalias@aerifal.cx>2012-10-06 16:56:35 -0400
commit92e1cd9b0ba9a8fa86e0346b121e159fb88f99bc (patch)
tree1ef7ad7ecd6a6e70e9ab442c52da8fdb29f80538 /src/ldso
parent6a2eaa3c5bbb8cc272cf6a4b7a9766a89e9b2c61 (diff)
downloadmusl-92e1cd9b0ba9a8fa86e0346b121e159fb88f99bc.tar.gz
don't crash if TLS library is loaded into process with no thread pointer
Diffstat (limited to 'src/ldso')
-rw-r--r--src/ldso/dynlink.c5
1 files changed, 5 insertions, 0 deletions
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;