Fix for a null pointer exception in new memory buffer