Use std::shared_ptr to refer to FdEntity (#2541)

FdEntity may have multiple references due to ChangeEntityToTempPath.
This relies on the std::enable_shared_from_this helper to create a
std::shared_ptr from this.  Fixes #2532.
This commit is contained in:
Andrew Gaul
2024-10-20 14:56:29 +09:00
committed by GitHub
parent a505cebf9b
commit 4b6e53223b
4 changed files with 13 additions and 12 deletions

View File

@ -1086,7 +1086,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
}
// Change entity key in manager mapping
FdManager::get()->ChangeEntityToTempPath(this, path.c_str());
FdManager::get()->ChangeEntityToTempPath(get_shared_ptr(), path.c_str());
// open temporary file
int tmpfd;