Crash prevention, if you play with non-manadory TLS. Also a file descriptor leak got fixed.
Authored by: dannybackx 2019-06-10
Parent: [r247]
Child: [r249]