1
0
Fork 0

Reserve the trackFile shared_ptr prior to its test

This commit is contained in:
krcroft 2020-02-28 18:57:53 -08:00 committed by Patryk Obara
parent 5bbf876f0c
commit 908ddafb5f

View file

@ -488,13 +488,16 @@ bool CDROM_Interface_Image::GetMediaTrayStatus(bool& mediaPresent, bool& mediaCh
bool CDROM_Interface_Image::PlayAudioSector(uint64_t start, uint64_t len)
{
// Find the track that holds the requested sector
track_const_iter track(GetTrack(start));
std::shared_ptr<TrackFile> trackFile;
if (track != tracks.end() && track->file)
trackFile = track->file;
// Guard: sanity check the request beyond what GetTrack already checks
if (len == 0
|| track == tracks.end()
|| !trackFile
|| track->attr == 0x40
|| !track->file
|| !player.channel
|| !player.mutex) {
StopAudio();
@ -521,8 +524,6 @@ bool CDROM_Interface_Image::PlayAudioSector(uint64_t start, uint64_t len)
+ clamp(relative_start, 0, static_cast<int>(track->length - 1))
* track->sectorSize);
std::shared_ptr<TrackFile> trackFile(track->file);
// Guard: Bail if our track could not be seeked
if (!trackFile->seek(offset)) {
LOG_MSG("CDROM: Track %d failed to seek to byte %u, so cancelling playback",