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

View File

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