Revision | a7d538fddb21427681704e027e2fdea2bed686c7 (tree) |
---|---|
Zeit | 2018-08-10 23:02:45 |
Autor | Christophe Lyon <christophe.lyon@st.c...> |
Commiter | Waldemar Brodkorb |
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>
@@ -544,7 +544,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, | ||
544 | 544 | result = 0; |
545 | 545 | unsigned int *const ptr = &__nptl_nthreads; |
546 | 546 | |
547 | - if (! atomic_decrement_and_test (ptr)) | |
547 | + if (ptr && ! atomic_decrement_and_test (ptr)) | |
548 | 548 | /* Not much left to do but to exit the thread, not the process. */ |
549 | 549 | __exit_thread_inline (0); |
550 | 550 | } |