[pulseaudio-discuss] [PATCH] stream-interaction: Fix a memory leak

Tanu Kaskinen tanuk at iki.fi
Wed Aug 10 16:33:07 UTC 2016


On Wed, 2016-08-10 at 21:25 +0530, Arun Raghavan wrote:
> roles_in_group can be used from an in-place split since we don't need to
> store it.
> 
> CID: 1352053
> ---
>  src/modules/stream-interaction.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/modules/stream-interaction.c b/src/modules/stream-interaction.c
> index 7a476c3..c787544 100644
> --- a/src/modules/stream-interaction.c
> +++ b/src/modules/stream-interaction.c
> @@ -396,10 +396,11 @@ int pa_stream_interaction_init(pa_module *m, const char* const v_modargs[]) {
>      roles = pa_modargs_get_value(ma, "trigger_roles", NULL);
>      if (roles) {
>          const char *group_split_state = NULL;
> -        char *roles_in_group = NULL;
> +        const char *roles_in_group = NULL;
> +        int l;
>          i = 0;
> -        while ((roles_in_group = pa_split(roles, "/", &group_split_state))) {
> -            if (roles_in_group[0] != '\0') {
> +        while ((roles_in_group = pa_split_in_place(roles, "/", &l, &group_split_state))) {
> +            if (l > 0) {
>                  const char *split_state = NULL;
>                  char *n = NULL;
>                  while ((n = pa_split(roles_in_group, ",", &split_state))) {

roles_in_group isn't NULL-terminated if you use pa_split_in_place(),
but pa_split() assumes that it is NULL-terminated.

-- 
Tanu


More information about the pulseaudio-discuss mailing list