[alsa-devel] [PATCH - JACK plugin 2/2] jack: Support to connect multiple JACK ports with same ALSA channel
Takashi Iwai
tiwai at suse.de
Tue Jan 29 14:45:16 CET 2019
On Thu, 24 Jan 2019 15:42:55 +0100,
<twischer at de.adit-jv.com> wrote:
>
> @@ -53,6 +61,32 @@ typedef struct {
> bool xrun_detected;
> } snd_pcm_jack_t;
>
> +
> +/* adds one element to the head of the list */
> +static int snd_pcm_jack_port_list_add(snd_pcm_jack_t *jack,
> + const unsigned int channel,
> + const char * const name)
> +{
> + const size_t name_size = strlen(name) + 1;
> + const size_t elem_size = sizeof(snd_pcm_jack_port_list_t) + name_size;
> + snd_pcm_jack_port_list_t *elem = NULL;
> +
> + if (name == NULL)
> + return -EINVAL;
name is already dereferenced in strlen(), so it's too late here.
i.e. name_size has to be evaluated after this NULL check, if any.
Or just drop this NULL check. It's an internal function and the name
is never NULL, practically seen.
> + elem = calloc(1, elem_size);
> + if (elem == NULL)
> + return -ENOMEM;
> +
> + strncpy(elem->name, name, name_size);
> + elem->name[name_size-1] = 0x00;
name_size is the exact size of string + 1, so this is equivalent with
strcpy().
thanks,
Takashi
More information about the Alsa-devel
mailing list