Skip to content

kcoredirlister: Remove iterator assert, use if instead

In cases where user adds files to a directory which parent directory is not readable for the user, these asserts would cause a crash, since the code would try to iterate over an empty list:

Due to reinsert using parent folder of visible, which is hidden, we have no permissions to read anything in hidden so we get an empty list. Without if (it != dirItem->lstItems.end()) this will cause a crash.

This would be okay if we did not allow users browse folders that we can read inside folders that we can't read. However, we allow this behavior if user manually types the path to the Dolphin URL bar for example.

Instead we should just check if the iterator has reached it's end, and just silently do nothing instead. If user is inside a hidden folder, we can't really do any updates to our directory listing views etc. anyway.

I also added similar change to remove since it does same thing as reinsert, just with one function call less.

BUG:493319

A test case for this is following using Dolphin:

  1. Open Dolphin, Press F7 to open the folder panel
  2. Go to any folder
  3. run mkdir -p hidden/visible
  4. run chmod u-r hidden
  5. run chmod go-rw hidden
  6. Type in URL bar path/hidden/visible
  7. Add a new folder
Edited by Akseli Lahtinen

Merge request reports

Loading