]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Don't assume channels always have logic data
authorSoeren Apel <redacted>
Wed, 14 Jun 2017 21:37:18 +0000 (23:37 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:08 +0000 (00:37 +0200)
It could be that a signal was assigned to a decoder when it
had a conversion enabled, then the conversion was removed.
This means the signal may no longer provide logic data but
as it's still assigned to the decoder, it will try to access
the logic data and... boom.

pv/data/decodesignal.cpp

index 5701aeb09b5eff7262d83b5336ba4d370cc91b4f..e8206a088bac285077271d0d5f6db08cd442649b 100644 (file)
@@ -181,6 +181,13 @@ void DecodeSignal::begin_decode()
                return;
        }
 
                return;
        }
 
+       // Make sure that all assigned channels still provide logic data
+       // (can happen when a converted signal was assigned but the
+       // conversion removed in the meanwhile)
+       for (data::DecodeChannel &ch : channels_)
+               if (ch.assigned_signal && !(ch.assigned_signal->logic_data() != nullptr))
+                       ch.assigned_signal = nullptr;
+
        // Check that all decoders have the required channels
        for (const shared_ptr<decode::Decoder> &dec : stack_)
                if (!dec->have_required_channels()) {
        // Check that all decoders have the required channels
        for (const shared_ptr<decode::Decoder> &dec : stack_)
                if (!dec->have_required_channels()) {