libc - Fix bogus pthread_getspecific() return value due to bug in nmalloc
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 30 Jan 2011 21:44:11 +0000 (13:44 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 30 Jan 2011 21:47:13 +0000 (13:47 -0800)
commitbfa38597b518100bb00712479ce7836a551e04a2
treeedcceecac7ca173c7bdc1291a801292bee3feb00
parentdb31565a3a1ee099db5cd29a9d3ebf64792fbf3e
libc - Fix bogus pthread_getspecific() return value due to bug in nmalloc

* nmalloc was calling pthread_set_specific() prior to calling
  pthread_key_create(), causing it to use key 0 which might already
  have been allocated for other purposes.

* Reorder initializations in _nmalloc_thr_init() to solve the problem.

* This also solves certain application crashes (mail/milter-greylist).

Reported-by: Francois Tigeot <ftigeot@wolfpond.org>
lib/libc/stdlib/nmalloc.c