From 2c2dd8073c10d6663faa8f67de3ba14dbda51084 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 17 Aug 2017 15:32:24 -0400 Subject: [PATCH] Modified to return nullptr if asked for an extended disk image track that doesn't exist. --- Storage/Disk/Formats/CPCDSK.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Storage/Disk/Formats/CPCDSK.cpp b/Storage/Disk/Formats/CPCDSK.cpp index ba57c539b..b67d5a007 100644 --- a/Storage/Disk/Formats/CPCDSK.cpp +++ b/Storage/Disk/Formats/CPCDSK.cpp @@ -57,8 +57,14 @@ std::shared_ptr CPCDSK::get_uncached_track_at_position(unsigned int head, // All DSK images reserve 0x100 bytes for their headers. long file_offset = 0x100; if(is_extended_) { - // Tracks are a variable size in the original DSK file format; sum the lengths - // of all tracks prior to the interesting one to get a file offset. + // Tracks are a variable size in the original DSK file format. + + // Check that there is anything stored for this track. + if(!track_sizes_[chronological_track]) { + return nullptr; + } + + // Sum the lengths of all tracks prior to the interesting one to get a file offset. unsigned int t = 0; while(t < chronological_track && t < track_sizes_.size()) { file_offset += track_sizes_[t];