core: Fix leak in TLS. #6231