From: Uwe Hermann Date: Sat, 21 Apr 2018 21:27:00 +0000 (+0200) Subject: soft-trigger: Use g_try_malloc() for potentially large allocation. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d52107a1592bd0a01ab89398a29e658e49a059f5;p=libsigrok.git soft-trigger: Use g_try_malloc() for potentially large allocation. This fixes bug #1000. --- diff --git a/src/soft-trigger.c b/src/soft-trigger.c index 50fdd41c..083b003a 100644 --- a/src/soft-trigger.c +++ b/src/soft-trigger.c @@ -38,7 +38,11 @@ SR_PRIV struct soft_trigger_logic *soft_trigger_logic_new( stl->unitsize = (g_slist_length(sdi->channels) + 7) / 8; stl->prev_sample = g_malloc0(stl->unitsize); stl->pre_trigger_size = stl->unitsize * pre_trigger_samples; - stl->pre_trigger_buffer = g_malloc(stl->pre_trigger_size); + stl->pre_trigger_buffer = g_try_malloc(stl->pre_trigger_size); + if (!stl->pre_trigger_buffer) { + soft_trigger_logic_free(stl); + return NULL; + } stl->pre_trigger_head = stl->pre_trigger_buffer; if (stl->pre_trigger_size > 0 && !stl->pre_trigger_buffer) {