The mutex attributes object should be destroyed after been used.
Where here also check return value of pthread_mutexattr_init() to
prevent potential writing in unallocated memory or NULL pointer
dereferencing when the system is out of memory.
This fix is inspired by the recent commit a03f768612ad
(libstdthreads: destroy mutexattr in mtx_init()) .
MFC after: 1 week