X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdevice.c;h=d87d2904a313f74e870a370279cbd64d42110d7a;hb=HEAD;hp=7973d1e53629e0ccba5d4bf76b1e5f1fa8e37034;hpb=460c13346e628b510188aa5ada6179abcf178014;p=libsigrok.git diff --git a/src/device.c b/src/device.c index 7973d1e5..5c681378 100644 --- a/src/device.c +++ b/src/device.c @@ -67,7 +67,7 @@ SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi, ch->index = index; ch->type = type; ch->enabled = enabled; - if (name) + if (name && *name) ch->name = g_strdup(name); sdi->channels = g_slist_append(sdi->channels, ch); @@ -120,6 +120,8 @@ SR_API int sr_dev_channel_name_set(struct sr_channel *channel, { if (!channel) return SR_ERR_ARG; + if (!name || !*name) + return SR_ERR_ARG; g_free(channel->name); channel->name = g_strdup(name); @@ -489,7 +491,8 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type, if (!sdi || sdi->inst_type != SR_INST_USER || index < 0) return SR_ERR_ARG; - sr_channel_new(sdi, index, type, TRUE, name); + if (!sr_channel_new(sdi, index, type, TRUE, name)) + return SR_ERR_DATA; return SR_OK; }