if (enum_ctl->texts != NULL) {
for (i = 0; i < num_items; i++) {
if (enum_ctl->texts[i] != NULL)
- strncpy(ec->texts[i], enum_ctl->texts[i],
- SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ snd_strlcpy(ec->texts[i], enum_ctl->texts[i],
+ SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
}
}
if (fclose(fp) == EOF) {
SNDERR("Cannot close data file.");
- ret = -errno;
- goto err;
+ return -errno;
}
return 0;
err:
+ fclose(fp);
if (priv)
free(priv);
return ret;
static int copy_tuples(struct tplg_elem *elem,
struct tplg_vendor_tuples *tuples, struct tplg_vendor_tokens *tokens)
{
- struct snd_soc_tplg_private *priv = elem->data;
+ struct snd_soc_tplg_private *priv = elem->data, *priv2;
struct tplg_tuple_set *tuple_set;
struct tplg_tuple *tuple;
struct snd_soc_tplg_vendor_array *array;
return -EINVAL;
}
- if (priv != NULL)
- priv = realloc(priv, sizeof(*priv) + size);
- else
+ if (priv != NULL) {
+ priv2 = realloc(priv, sizeof(*priv) + size);
+ if (priv2 == NULL) {
+ free(priv);
+ priv = NULL;
+ } else {
+ priv = priv2;
+ }
+ } else {
priv = calloc(1, sizeof(*priv) + size);
+ }
if (!priv)
return -ENOMEM;
ret = snd_input_stdio_attach(&in, fp, 1);
if (ret < 0) {
+ fclose(fp);
SNDERR("error: could not attach stdio %s", file);
- goto err;
+ return ret;
}
ret = snd_config_top(&top);
if (ret < 0)
err_load:
snd_config_delete(top);
err:
- fclose(fp);
+ snd_input_close(in);
return ret;
}