Tiny optimization in safe_open.

We already know that next_component is neither null nor empty in the
second branch, because of 7f137f0ad5.

(cherry picked from commit e890b4a420a9d7857c8a6a89a5aa5db061045faf)
Fix failure to open paths ending in a slash.

Redmine #3905.

(cherry picked from commit 7fc5a0a65ebe0920b881a338b89482656bafeae6)
Fix incorrect return value for empty string in safe_open.

(cherry picked from commit 7f137f0ad57085a8100bbfa73efd6f06d07678a4)
Update ChangeLog with backported fixes