output/srzip: fix potential "use after free"
The compiler marks a potential use after free, which the current implementation won't trigger. The error only occurs when a sigrok channel is neither logic nor analog. Address the issue nevertheless, to silence the compiler warning, and to protect against possible programming errors when a future implementation should support more channel types. This was reported by clang's scan-build.
This commit is contained in:
parent
499f5045dd
commit
f396351704
|
@ -150,6 +150,7 @@ static int zip_create(const struct sr_output *o)
|
||||||
if (!ch->enabled)
|
if (!ch->enabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
s = NULL;
|
||||||
switch (ch->type) {
|
switch (ch->type) {
|
||||||
case SR_CHANNEL_LOGIC:
|
case SR_CHANNEL_LOGIC:
|
||||||
s = g_strdup_printf("probe%d", ch->index + 1);
|
s = g_strdup_printf("probe%d", ch->index + 1);
|
||||||
|
@ -160,8 +161,10 @@ static int zip_create(const struct sr_output *o)
|
||||||
index++;
|
index++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_key_file_set_string(meta, devgroup, s, ch->name);
|
if (s) {
|
||||||
g_free(s);
|
g_key_file_set_string(meta, devgroup, s, ch->name);
|
||||||
|
g_free(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metabuf = g_key_file_to_data(meta, &metalen, NULL);
|
metabuf = g_key_file_to_data(meta, &metalen, NULL);
|
||||||
|
|
Loading…
Reference in New Issue