Call Rename outside AutoFdEntity scope (#2528)

This avoids a use-after-free in the destructor.
This commit is contained in:
Andrew Gaul 2024-09-28 15:25:02 +09:00 committed by GitHub
parent e8f1e3473c
commit 52c10cd45d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1507,11 +1507,10 @@ static int rename_object(const char* from, const char* to, bool update_ctime)
if(0 != (result = put_headers(to, meta, true, /* use_st_size= */ false))){
return result;
}
// rename
FdManager::get()->Rename(from, to);
}
FdManager::get()->Rename(from, to);
// Remove file
result = s3fs_unlink(from);
@ -1562,9 +1561,10 @@ static int rename_object_nocopy(const char* from, const char* to, bool update_ct
S3FS_PRN_ERR("could not upload file(%s): result=%d", to, result);
return result;
}
FdManager::get()->Rename(from, to);
}
FdManager::get()->Rename(from, to);
// Remove file
result = s3fs_unlink(from);