Fixed issue where writing with an unitialized buffer would crash