[runtime] Switch getenv to use heap memory