Skip to content

set_fs_directory_to_opposite: Fix segv when no directory is chosen

When doing CTRL+LEFT or CTRL+RIGHT, "GnomeCmdMainWin::set_fs_directory_to_opposite" is executed. When a file list is chosen and active, set_fs_directory_to_opposite try to set the opposite directory to the chosen list. However, when no file is chosen and any file list is inactive, get_selected_file() returns nullptr, this leads file->GetGfileAttributeUInt32() segfault.

(Note that with optimization, even if file is nullptr, file->GetGfileAttributeUInt32() will be usually called, because compiler guesses file cannot be null when compilation. But in file->GetGfileAttributeUInt32(), this->gFile is accessed, which causes segfault anyway.)

To fix this, check if get_selected_file() returned non-null pointer or not (i.e. some file list is active or not.)

Fixes #104 (closed)

Merge request reports