Fix some uses-after-free due to terrible StdBuf semantics