aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Wilson <ksattic@gmail.com>2016-01-09 10:26:57 -0800
committerSimon Wilson <ksattic@gmail.com>2016-01-09 10:27:02 -0800
commitd131cf241b256f55df8d36699f41e630edd78701 (patch)
treecdee5319fb047d63ad701cdebc8afcb948baf8e3
parent1f8145a46a7386369e771bc5abac8cefed6e945f (diff)
tinymix: don't get byte array if size is zero
Fixes an error if the number of bytes available is zero. Also remove unused len variable.
-rw-r--r--tinymix.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/tinymix.c b/tinymix.c
index 71dd206..6e4b9a0 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -132,7 +132,6 @@ static void tinymix_detail_control(struct mixer *mixer, const char *control,
int min, max;
int ret;
char *buf = NULL;
- size_t len;
if (isdigit(control[0]))
ctl = mixer_get_ctl(mixer, atoi(control));
@@ -147,16 +146,14 @@ static void tinymix_detail_control(struct mixer *mixer, const char *control,
type = mixer_ctl_get_type(ctl);
num_values = mixer_ctl_get_num_values(ctl);
- if (type == MIXER_CTL_TYPE_BYTE) {
-
+ if ((type == MIXER_CTL_TYPE_BYTE) && (num_values > 0)) {
buf = calloc(1, num_values);
if (buf == NULL) {
fprintf(stderr, "Failed to alloc mem for bytes %d\n", num_values);
return;
}
- len = num_values;
- ret = mixer_ctl_get_array(ctl, buf, len);
+ ret = mixer_ctl_get_array(ctl, buf, num_values);
if (ret < 0) {
fprintf(stderr, "Failed to mixer_ctl_get_array\n");
free(buf);