]> sigrok.org Git - libsigrok.git/commitdiff
soft-trigger: Fix an issue causing triggers to not work.
authorUwe Hermann <redacted>
Tue, 24 Apr 2018 06:55:36 +0000 (08:55 +0200)
committerUwe Hermann <redacted>
Tue, 24 Apr 2018 14:56:07 +0000 (16:56 +0200)
src/soft-trigger.c

index 083b003a6cd6f297cd6f14f099b9a9eaab05d581..c92365e2baf4eb43aea24baf5115d7c871950ea0 100644 (file)
@@ -39,7 +39,12 @@ SR_PRIV struct soft_trigger_logic *soft_trigger_logic_new(
        stl->prev_sample = g_malloc0(stl->unitsize);
        stl->pre_trigger_size = stl->unitsize * pre_trigger_samples;
        stl->pre_trigger_buffer = g_try_malloc(stl->pre_trigger_size);
-       if (!stl->pre_trigger_buffer) {
+       if (pre_trigger_samples > 0 && !stl->pre_trigger_buffer) {
+               /*
+                * Error out if g_try_malloc() failed (or was invoked as
+                * g_try_malloc(0)) *and* more than 0 pretrigger samples
+                * were requested.
+                */
                soft_trigger_logic_free(stl);
                return NULL;
        }