mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
- check the return value of malloc & co.
This commit is contained in:
parent
7e6569e300
commit
d91948db49
7 changed files with 42 additions and 0 deletions
|
|
@ -2642,6 +2642,10 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
|
||||||
if (!func_name) {
|
if (!func_name) {
|
||||||
int len = 16 + strlen(str) + 1;
|
int len = 16 + strlen(str) + 1;
|
||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
|
if (! buf) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
snprintf(buf, len, "snd_config_hook_%s", str);
|
snprintf(buf, len, "snd_config_hook_%s", str);
|
||||||
buf[len-1] = '\0';
|
buf[len-1] = '\0';
|
||||||
func_name = buf;
|
func_name = buf;
|
||||||
|
|
@ -3423,6 +3427,10 @@ static int _snd_config_evaluate(snd_config_t *src,
|
||||||
if (!func_name) {
|
if (!func_name) {
|
||||||
int len = 9 + strlen(str) + 1;
|
int len = 9 + strlen(str) + 1;
|
||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
|
if (! buf) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
snprintf(buf, len, "snd_func_%s", str);
|
snprintf(buf, len, "snd_func_%s", str);
|
||||||
buf[len-1] = '\0';
|
buf[len-1] = '\0';
|
||||||
func_name = buf;
|
func_name = buf;
|
||||||
|
|
|
||||||
|
|
@ -439,6 +439,8 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
||||||
}
|
}
|
||||||
assert(!adpcm->states);
|
assert(!adpcm->states);
|
||||||
adpcm->states = malloc(adpcm->plug.slave->channels * sizeof(*adpcm->states));
|
adpcm->states = malloc(adpcm->plug.slave->channels * sizeof(*adpcm->states));
|
||||||
|
if (adpcm->states == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -923,6 +923,8 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, snd_config_t *cfg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
dmix->bindings = malloc(count * sizeof(unsigned int));
|
dmix->bindings = malloc(count * sizeof(unsigned int));
|
||||||
|
if (dmix->bindings == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
for (chn = 0; chn < count; chn++)
|
for (chn = 0; chn < count; chn++)
|
||||||
dmix->bindings[chn] = UINT_MAX; /* don't route */
|
dmix->bindings[chn] = UINT_MAX; /* don't route */
|
||||||
snd_config_for_each(i, next, cfg) {
|
snd_config_for_each(i, next, cfg) {
|
||||||
|
|
|
||||||
|
|
@ -771,6 +771,8 @@ static int snd_pcm_ladspa_check_dir(snd_pcm_ladspa_plugin_t * const plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = malloc(len + strlen(dirent->d_name) + 1 + need_slash);
|
filename = malloc(len + strlen(dirent->d_name) + 1 + need_slash);
|
||||||
|
if (filename == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
strcpy(filename, path);
|
strcpy(filename, path);
|
||||||
if (need_slash)
|
if (need_slash)
|
||||||
strcat(filename, "/");
|
strcat(filename, "/");
|
||||||
|
|
@ -880,6 +882,8 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug,
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
array = (unsigned int *)calloc(count, sizeof(unsigned int));
|
array = (unsigned int *)calloc(count, sizeof(unsigned int));
|
||||||
|
if (! array)
|
||||||
|
return -ENOMEM;
|
||||||
memset(array, 0xff, count * sizeof(unsigned int));
|
memset(array, 0xff, count * sizeof(unsigned int));
|
||||||
io->port_bindings_size = count;
|
io->port_bindings_size = count;
|
||||||
io->port_bindings = array;
|
io->port_bindings = array;
|
||||||
|
|
@ -928,6 +932,8 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug,
|
||||||
if ((lplug->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL))
|
if ((lplug->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL))
|
||||||
count++;
|
count++;
|
||||||
array = (LADSPA_Data *)calloc(count, sizeof(LADSPA_Data));
|
array = (LADSPA_Data *)calloc(count, sizeof(LADSPA_Data));
|
||||||
|
if (!array)
|
||||||
|
return -ENOMEM;
|
||||||
io->controls_size = count;
|
io->controls_size = count;
|
||||||
io->controls = array;
|
io->controls = array;
|
||||||
snd_config_for_each(i, next, controls) {
|
snd_config_for_each(i, next, controls) {
|
||||||
|
|
|
||||||
|
|
@ -696,8 +696,17 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
|
||||||
multi->slaves_count = slaves_count;
|
multi->slaves_count = slaves_count;
|
||||||
multi->master_slave = master_slave;
|
multi->master_slave = master_slave;
|
||||||
multi->slaves = calloc(slaves_count, sizeof(*multi->slaves));
|
multi->slaves = calloc(slaves_count, sizeof(*multi->slaves));
|
||||||
|
if (!multi->slaves) {
|
||||||
|
free(multi);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
multi->channels_count = channels_count;
|
multi->channels_count = channels_count;
|
||||||
multi->channels = calloc(channels_count, sizeof(*multi->channels));
|
multi->channels = calloc(channels_count, sizeof(*multi->channels));
|
||||||
|
if (!multi->channels) {
|
||||||
|
free(multi->slaves);
|
||||||
|
free(multi->channels);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
for (i = 0; i < slaves_count; ++i) {
|
for (i = 0; i < slaves_count; ++i) {
|
||||||
snd_pcm_multi_slave_t *slave = &multi->slaves[i];
|
snd_pcm_multi_slave_t *slave = &multi->slaves[i];
|
||||||
assert(slaves_pcm[i]->stream == stream);
|
assert(slaves_pcm[i]->stream == stream);
|
||||||
|
|
@ -914,6 +923,11 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
|
||||||
slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
|
slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
|
||||||
channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
|
channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
|
||||||
channels_schannel = calloc(channels_count, sizeof(*channels_schannel));
|
channels_schannel = calloc(channels_count, sizeof(*channels_schannel));
|
||||||
|
if (!slaves_id || !slaves_conf || !slaves_pcm || !slaves_channels ||
|
||||||
|
!channels_sidx || !channels_schannel) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto _free;
|
||||||
|
}
|
||||||
idx = 0;
|
idx = 0;
|
||||||
for (idx = 0; idx < channels_count; ++idx)
|
for (idx = 0; idx < channels_count; ++idx)
|
||||||
channels_sidx[idx] = -1;
|
channels_sidx[idx] = -1;
|
||||||
|
|
@ -1036,6 +1050,8 @@ _free:
|
||||||
free(channels_sidx);
|
free(channels_sidx);
|
||||||
if (channels_schannel)
|
if (channels_schannel)
|
||||||
free(channels_schannel);
|
free(channels_schannel);
|
||||||
|
if (slaves_id)
|
||||||
|
free(slaves_id);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#ifndef DOC_HIDDEN
|
#ifndef DOC_HIDDEN
|
||||||
|
|
|
||||||
|
|
@ -1630,6 +1630,10 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
||||||
goto _free;
|
goto _free;
|
||||||
}
|
}
|
||||||
channels_map = calloc(channels, sizeof(*channels_map));
|
channels_map = calloc(channels, sizeof(*channels_map));
|
||||||
|
if (! channels_map) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto _free;
|
||||||
|
}
|
||||||
|
|
||||||
snd_config_for_each(i, next, bindings) {
|
snd_config_for_each(i, next, bindings) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
|
|
|
||||||
|
|
@ -795,6 +795,8 @@ int snd_is_local(struct hostent *hent)
|
||||||
|
|
||||||
conf.ifc_len = numreqs * sizeof(struct ifreq);
|
conf.ifc_len = numreqs * sizeof(struct ifreq);
|
||||||
conf.ifc_buf = malloc((unsigned int) conf.ifc_len);
|
conf.ifc_buf = malloc((unsigned int) conf.ifc_len);
|
||||||
|
if (! conf.ifc_buf)
|
||||||
|
return -ENOMEM;
|
||||||
while (1) {
|
while (1) {
|
||||||
err = ioctl(s, SIOCGIFCONF, &conf);
|
err = ioctl(s, SIOCGIFCONF, &conf);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
|
@ -806,6 +808,8 @@ int snd_is_local(struct hostent *hent)
|
||||||
numreqs *= 2;
|
numreqs *= 2;
|
||||||
conf.ifc_len = numreqs * sizeof(struct ifreq);
|
conf.ifc_len = numreqs * sizeof(struct ifreq);
|
||||||
conf.ifc_buf = realloc(conf.ifc_buf, (unsigned int) conf.ifc_len);
|
conf.ifc_buf = realloc(conf.ifc_buf, (unsigned int) conf.ifc_len);
|
||||||
|
if (! conf.ifc_buf)
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
numreqs = conf.ifc_len / sizeof(struct ifreq);
|
numreqs = conf.ifc_len / sizeof(struct ifreq);
|
||||||
for (i = 0; i < numreqs; ++i) {
|
for (i = 0; i < numreqs; ++i) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue