Fix use-after-frees when opening files from the MRU lists

Pass the paths to open by value to avoid ending up with a dangling
reference to a path stored in the MRU list which has been invalidated by
adding or removing items.

Closes #1777.
This commit is contained in:
Thomas Goyne 2014-06-23 16:29:46 -07:00
parent 4ce1283bbb
commit 6661c6a808
2 changed files with 10 additions and 10 deletions

View file

@ -157,7 +157,7 @@ bool Project::DoLoadSubtitles(agi::fs::path const& path, std::string encoding, P
return true;
}
void Project::LoadSubtitles(agi::fs::path const& path, std::string encoding) {
void Project::LoadSubtitles(agi::fs::path path, std::string encoding) {
ProjectProperties properties;
if (DoLoadSubtitles(path, encoding, properties))
LoadUnloadFiles(properties);
@ -273,7 +273,7 @@ void Project::DoLoadAudio(agi::fs::path const& path, bool quiet) {
AnnounceAudioProviderModified(audio_provider.get());
}
void Project::LoadAudio(agi::fs::path const& path) {
void Project::LoadAudio(agi::fs::path path) {
DoLoadAudio(path, false);
}
@ -327,7 +327,7 @@ bool Project::DoLoadVideo(agi::fs::path const& path) {
return true;
}
void Project::LoadVideo(agi::fs::path const& path) {
void Project::LoadVideo(agi::fs::path path) {
if (path.empty()) return;
if (!DoLoadVideo(path)) return;
if (OPT_GET("Video/Open Audio")->GetBool() && audio_file != video_file && video_provider->HasAudio())
@ -357,7 +357,7 @@ void Project::DoLoadTimecodes(agi::fs::path const& path) {
AnnounceTimecodesModified(timecodes);
}
void Project::LoadTimecodes(agi::fs::path const& path) {
void Project::LoadTimecodes(agi::fs::path path) {
try {
DoLoadTimecodes(path);
}
@ -383,7 +383,7 @@ void Project::DoLoadKeyframes(agi::fs::path const& path) {
AnnounceKeyframesModified(keyframes);
}
void Project::LoadKeyframes(agi::fs::path const& path) {
void Project::LoadKeyframes(agi::fs::path path) {
try {
DoLoadKeyframes(path);
}

View file

@ -69,26 +69,26 @@ public:
Project(agi::Context *context);
~Project();
void LoadSubtitles(agi::fs::path const& path, std::string encoding="");
void LoadSubtitles(agi::fs::path path, std::string encoding="");
void CloseSubtitles();
bool CanLoadSubtitlesFromVideo() const { return video_has_subtitles; }
void LoadAudio(agi::fs::path const& path);
void LoadAudio(agi::fs::path path);
void CloseAudio();
::AudioProvider *AudioProvider() const { return audio_provider.get(); }
agi::fs::path const& AudioName() const { return audio_file; }
void LoadVideo(agi::fs::path const& path);
void LoadVideo(agi::fs::path path);
void CloseVideo();
AsyncVideoProvider *VideoProvider() const { return video_provider.get(); }
agi::fs::path const& VideoName() const { return video_file; }
void LoadTimecodes(agi::fs::path const& path);
void LoadTimecodes(agi::fs::path path);
void CloseTimecodes();
bool CanCloseTimecodes() const { return !timecodes_file.empty(); }
agi::vfr::Framerate const& Timecodes() const { return timecodes; }
void LoadKeyframes(agi::fs::path const& path);
void LoadKeyframes(agi::fs::path path);
void CloseKeyframes();
bool CanCloseKeyframes() const { return !keyframes_file.empty(); }
std::vector<int> const& Keyframes() const { return keyframes; }