From: Takashi Iwai Date: Wed, 17 Aug 2005 17:27:16 +0000 (+0000) Subject: Misc fixes X-Git-Tag: v1.0.10rc1~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=ea77e08cc6d2e3126f0159ee102b98313bef264e;p=alsa-lib.git Misc fixes Fixes of spots found via valgrind - non-freed chunks after snd_config_get_ascii() - zero-fill records (to make valgrind happy) - compile warning fixes --- diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index c116f0f4..1f2cba86 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1962,8 +1962,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, val = NULL; snd_config_get_ascii(pcm_conf, &val); SNDERR("Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val); - if (val) - free(val); + free(val); return -EINVAL; } err = snd_config_search(pcm_conf, "type", &conf); diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index f69f0df9..8ce406bd 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -198,6 +198,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm) if (server) unlink(filename); + memset(addr, 0, size); /* make valgrind happy */ addr->sun_family = AF_LOCAL; memcpy(addr->sun_path, filename, l); @@ -456,7 +457,8 @@ int snd_pcm_direct_async(snd_pcm_t *pcm, int sig, pid_t pid) return snd_timer_async(dmix->timer, sig, pid); } -static inline void process_timer_event(snd_pcm_direct_t *dmix, snd_timer_tread_t *te) +static inline void process_timer_event(snd_pcm_direct_t *dmix ATTRIBUTE_UNUSED, + snd_timer_tread_t *te ATTRIBUTE_UNUSED) { #if 0 printf("te->event = %i\n", te->event); diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index c9cfdcc0..40d072dd 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -1080,9 +1080,11 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, } if (isdigit(*perm) == 0) { SNDERR("The field ipc_perm must be a valid file permission"); + free(perm); return -EINVAL; } ipc_perm = strtol(perm, &endp, 8); + free(perm); continue; } if (strcmp(id, "ipc_gid") == 0) { @@ -1097,12 +1099,14 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, struct group *grp = getgrnam(group); if (grp == NULL) { SNDERR("The field ipc_gid must be a valid group (create group %s)", group); + free(group); return -EINVAL; } ipc_gid = grp->gr_gid; } else { ipc_perm = strtol(group, &endp, 10); } + free(group); continue; } if (strcmp(id, "ipc_key_add_uid") == 0) { diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index 30a57bc7..031f8ea5 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -865,9 +865,11 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, } if (isdigit(*perm) == 0) { SNDERR("The field ipc_perm must be a valid file permission"); + free(perm); return -EINVAL; } ipc_perm = strtol(perm, &endp, 8); + free(perm); continue; } if (strcmp(id, "ipc_gid") == 0) { @@ -881,13 +883,15 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, if (isdigit(*group) == 0) { struct group *grp = getgrnam(group); if (group == NULL) { - SNDERR("The field ipc_gid must be a valid group (create group %s)", grp); + SNDERR("The field ipc_gid must be a valid group (create group %s)", group); + free(group); return -EINVAL; } ipc_gid = grp->gr_gid; } else { ipc_perm = strtol(group, &endp, 10); } + free(group); continue; } if (strcmp(id, "ipc_key_add_uid") == 0) { diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c index e2da4b71..4ee52cbb 100644 --- a/src/pcm/pcm_dsnoop.c +++ b/src/pcm/pcm_dsnoop.c @@ -750,9 +750,11 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, } if (isdigit(*perm) == 0) { SNDERR("The field ipc_perm must be a valid file permission"); + free(perm); return -EINVAL; } ipc_perm = strtol(perm, &endp, 8); + free(perm); continue; } if (strcmp(id, "ipc_gid") == 0) { @@ -766,13 +768,15 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, if (isdigit(*group) == 0) { struct group *grp = getgrnam(group); if (group == NULL) { - SNDERR("The field ipc_gid must be a valid group (create group %s)", grp); + SNDERR("The field ipc_gid must be a valid group (create group %s)", group); + free(group); return -EINVAL; } ipc_gid = grp->gr_gid; } else { ipc_perm = strtol(group, &endp, 10); } + free(group); continue; } if (strcmp(id, "ipc_key_add_uid") == 0) { diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 93bf8185..3808aaae 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -550,9 +550,11 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, } if (isdigit(*str) == 0) { SNDERR("The field perm must be a valid file permission"); + free(str); return -EINVAL; } perm = strtol(str, &endp, 8); + free(str); continue; } SNDERR("Unknown field %s", id);