Fix memory leak and potential undefined behavior in WString::Resize().