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

Arun Raghavan arun at arunraghavan.net
Wed Aug 10 16:52:27 UTC 2016


On Wed, 10 Aug 2016, at 10:03 PM, Tanu Kaskinen wrote:
> 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.

Drat, right. Different fix coming up.

-- Arun


More information about the pulseaudio-discuss mailing list