From: Jaroslav Kysela Date: Tue, 12 Jan 2016 15:25:42 +0000 (+0100) Subject: coverity fixes X-Git-Tag: v1.1.1~20 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=df20aa2a1ea9cbcb3eb96c5684c1a00de29e2730;p=alsa-lib.git coverity fixes --- diff --git a/aserver/aserver.c b/aserver/aserver.c index 1579da7b..ac20706b 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -93,6 +93,7 @@ static int make_inet_socket(int port) return result; } + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = INADDR_ANY; diff --git a/src/control/control.c b/src/control/control.c index 8504d076..328920d9 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -411,7 +411,7 @@ int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, bytes = 0; for (i = 0; i < items; ++i) bytes += strlen(names[i]) + 1; - buf = malloc(bytes); + buf = bytes ? malloc(bytes) : NULL; if (!buf) return -ENOMEM; info->value.enumerated.names_ptr = (uintptr_t)buf; diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c index 877a05e3..d38b44ef 100644 --- a/src/control/ctlparse.c +++ b/src/control/ctlparse.c @@ -62,7 +62,7 @@ static long get_integer(const char **ptr, long min, long max) val = strtol(s, &p, 0); if (*p == '.') { p++; - strtol(p, &p, 10); + (void)strtol(p, &p, 10); } if (*p == '%') { val = (long)convert_prange1(strtod(s, NULL), min, max); @@ -90,7 +90,7 @@ static long long get_integer64(const char **ptr, long long min, long long max) val = strtol(s, &p, 0); if (*p == '.') { p++; - strtol(p, &p, 10); + (void)strtol(p, &p, 10); } if (*p == '%') { val = (long long)convert_prange1(strtod(s, NULL), min, max); diff --git a/src/control/namehint.c b/src/control/namehint.c index b3e646eb..856957c7 100644 --- a/src/control/namehint.c +++ b/src/control/namehint.c @@ -559,6 +559,8 @@ int snd_device_name_hint(int card, const char *iface, void ***hints) if (err < 0) return err; err = snd_config_copy(&local_config_rw, local_config); + if (err < 0) + return err; list.list = NULL; list.count = list.allocated = 0; list.siface = iface; diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index 4b8299ed..c4b1fba3 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -888,6 +888,8 @@ static int snd_pcm_multi_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map) slave_maps[i] = calloc(multi->slaves[i].channels_count + 1, sizeof(int)); if (!slave_maps[i]) { + for (i++; i < multi->slaves_count; i++) + slave_maps[i] = NULL; err = -ENOMEM; goto error; }