X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=strutil.c;h=8b0203b01765cd06ff8fb35b07fb0df0309f0a1c;hb=4362438f1e2da14d04678327c403f9d75c4c0a48;hp=e5278dfe3fda303156eb05b62bc95577f71b4158;hpb=59df0c77e2906323290544ea62801831818ec096;p=libsigrok.git diff --git a/strutil.c b/strutil.c index e5278dfe..8b0203b0 100644 --- a/strutil.c +++ b/strutil.c @@ -22,6 +22,7 @@ #include #include #include +#include /** * Convert a numeric samplerate value to its "natural" string representation. @@ -114,7 +115,12 @@ char **sr_parse_triggerstring(struct sr_device *device, max_probes = g_slist_length(device->probes); error = FALSE; - triggerlist = g_malloc0(max_probes * sizeof(char *)); + + if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) { + sr_err("session file: %s: metafile malloc failed", __func__); + return NULL; + } + tokens = g_strsplit(triggerstring, ",", max_probes); trigger_types = device->plugin->get_device_info(0, SR_DI_TRIGGER_TYPES); if (trigger_types == NULL)