X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=instance.c;h=8d660a46454442cfa8c36e61d8e6e17042bdd79c;hp=a94118f2430de4991f70708522999fc49e02b53c;hb=1d757906a2f8c881fcbbd1915420aa80a9d5da36;hpb=25d3576134e7b57ca169e8e4ebd4e4ce5dcf62dd diff --git a/instance.c b/instance.c index a94118f..8d660a4 100644 --- a/instance.c +++ b/instance.c @@ -223,7 +223,7 @@ SRD_API int srd_inst_channel_set_all(struct srd_decoder_inst *di, return SRD_ERR_ARG; } - new_channelmap = g_malloc(sizeof(int) * di->dec_num_channels); + new_channelmap = g_malloc0(sizeof(int) * di->dec_num_channels); /* * For now, map all indexes to channel -1 (can be overridden later). @@ -263,11 +263,11 @@ SRD_API int srd_inst_channel_set_all(struct srd_decoder_inst *di, srd_dbg("Final channel map:"); num_required_channels = g_slist_length(di->decoder->channels); for (i = 0; i < di->dec_num_channels; i++) { - GSList *l = g_slist_nth(di->decoder->channels, i); - if (!l) - l = g_slist_nth(di->decoder->opt_channels, + GSList *ll = g_slist_nth(di->decoder->channels, i); + if (!ll) + ll = g_slist_nth(di->decoder->opt_channels, i - num_required_channels); - pdch = l->data; + pdch = ll->data; srd_dbg(" - PD ch idx %d (%s) = input data ch idx %d (%s)", i, pdch->id, new_channelmap[i], (i < num_required_channels) ? "required" : "optional");