- try {
- const DecodeSegment *segment = &(segments_.at(segment_id));
-
- const DecodeBinaryClass* bin_class = nullptr;
- for (const DecodeBinaryClass& bc : segment->binary_classes)
- if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
- bin_class = &bc;
-
- // Determine overall size before copying to resize dest vector only once
- uint64_t size = 0;
- uint64_t matches = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
- if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
- size += chunk.data.size();
- matches++;
- }
- dest->resize(size);
-
- uint64_t offset = 0;
- uint64_t matches2 = 0;
- for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
- if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
- memcpy(dest->data() + offset, chunk.data.data(), chunk.data.size());
- offset += chunk.data.size();
- matches2++;
-
- // Make sure we don't overwrite memory if the array grew in the meanwhile
- if (matches2 == matches)
- break;
- }
- } catch (out_of_range&) {
- // Do nothing
- }
+ if (segment_id >= segments_.size())
+ return;
+
+ const DecodeSegment *segment = &(segments_[segment_id]);
+
+ const DecodeBinaryClass* bin_class = nullptr;
+ for (const DecodeBinaryClass& bc : segment->binary_classes)
+ if ((bc.decoder == dec) && (bc.info->bin_class_id == bin_class_id))
+ bin_class = &bc;
+
+ // Determine overall size before copying to resize dest vector only once
+ uint64_t size = 0;
+ uint64_t matches = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
+ if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
+ size += chunk.data.size();
+ matches++;
+ }
+ dest->resize(size);
+
+ uint64_t offset = 0;
+ uint64_t matches2 = 0;
+ for (const DecodeBinaryDataChunk& chunk : bin_class->chunks)
+ if ((chunk.sample >= start_sample) && (chunk.sample < end_sample)) {
+ memcpy(dest->data() + offset, chunk.data.data(), chunk.data.size());
+ offset += chunk.data.size();
+ matches2++;
+
+ // Make sure we don't overwrite memory if the array grew in the meanwhile
+ if (matches2 == matches)
+ break;
+ }