[PATCH 2/2] remote: fix stream use-after-free