about summary refs log tree commit diff
diff options
context:
space:
mode:
-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;