The logic about which buffer it's going to use for saving is quite confusing.
This simply restores the logic from before 7584ccc28d while still guarding
against accessing null buffers.
Pull Request: https://projects.blender.org/blender/blender/pulls/136659