fix use-after-free when inserting found files into the map