RUBY-612 fixing usage of new buffer when potentially null