summaryrefslogtreecommitdiff
path: root/libc/misc/internals
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@st.com>2018-07-04 17:55:40 +0200
committerWaldemar Brodkorb <wbrodkorb@conet.de>2018-08-10 16:02:45 +0200
commita7d538fddb21427681704e027e2fdea2bed686c7 (patch)
treec4e52cb4ecd677ad0256da6e2c600dbbb9f030cf /libc/misc/internals
parent0f4ddec32ebf5796c5ea485f8fdae2f1ad429e1d (diff)
nptl threads: Fix bug in using a weak variable.
In case __nptl_nthreads is not defined in the final binary then avoid dereferencing the address since it's null. Anyway this means there is no other thread and so we must exit. * libc/misc/internals/__uClibc_main.c (__uClibc_main): Handle case where &__nptl_nthreads is null. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Diffstat (limited to 'libc/misc/internals')
-rw-r--r--libc/misc/internals/__uClibc_main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index d8286f20b..849bca8d4 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -544,7 +544,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
result = 0;
unsigned int *const ptr = &__nptl_nthreads;
- if (! atomic_decrement_and_test (ptr))
+ if (ptr && ! atomic_decrement_and_test (ptr))
/* Not much left to do but to exit the thread, not the process. */
__exit_thread_inline (0);
}