Range-based for should not be used when we are altering the container.
Use iterator explicitly instead.
Fixes: https://tracker.ceph.com/issues/53805
Signed-off-by: 胡玮文 <huww98@outlook.com>
(cherry picked from commit
d48a2cf7e2481cf9758f2934464ec6d9c35d898b)
return true;
}
- for (auto &it : subdir->items) {
- CDentry *dn = it.second;
+ for (auto it = subdir->items.begin(); it != subdir->items.end();) {
+ CDentry *dn = it->second;
+ it++;
CDentry::linkage_t *dnl = dn->get_linkage();
if (dnl->is_primary()) {
CInode *tin = dnl->get_inode();