]> sigrok.org Git - pulseview.git/blobdiff - pv/storesession.cpp
Fix #1038 by catching invalid cursor ranges
[pulseview.git] / pv / storesession.cpp
index 50815c26dcedfcaff7716f115b2eb376c371960a..494f2db3b91e7b8fe34ea1cfa56471f5ba4a8fc5 100644 (file)
@@ -145,6 +145,7 @@ bool StoreSession::start()
        uint64_t end_sample;
 
        if (sample_range_.first == sample_range_.second) {
+               // No sample range specified, save everything we have
                start_sample_ = 0;
                sample_count_ = any_segment->get_sample_count();
        } else {
@@ -159,6 +160,12 @@ bool StoreSession::start()
                }
        }
 
+       // Make sure the sample range is valid
+       if (start_sample_ > any_segment->get_sample_count()) {
+               error_ = tr("Can't save range without sample data.");
+               return false;
+       }
+
        // Begin storing
        try {
                const auto context = session_.device_manager().context();