Fix some NULL pointer dereferences in erdtls