Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on -l #175

Closed
J-u-n-o opened this issue May 8, 2020 · 3 comments
Closed

crash on -l #175

J-u-n-o opened this issue May 8, 2020 · 3 comments
Assignees
Labels

Comments

@J-u-n-o
Copy link

J-u-n-o commented May 8, 2020

Segmentation fault
Due to free-ing memory twice,
and subsequent free-ing of null pointers

file: playerctl-player.c
function: playerctl_list_players
Original the system_players were free-ed:

  /* g_list_concat: Adds the second GList onto the end of the first GList. Note that the elements of the second GList are not copied. They are used directly.*/
  GList *players = g_list_concat(session_players, system_players);

system_players = NULL;

  return players;
@J-u-n-o
Copy link
Author

J-u-n-o commented May 8, 2020

playerctl-cli.c
static int handle_list_all_flag()

GList *l = NULL;
for (l = player_names_list; l != NULL; l = l->next) {
    PlayerctlPlayerName *name = l->data;
   if (name->instance != NULL) {
        printf("%s\n", name->instance);
   } else {
       printf("[NULL]\n");
  }
}

@J-u-n-o
Copy link
Author

J-u-n-o commented May 8, 2020

playerctl-player-name.c
void playerctl_player_name_free(PlayerctlPlayerName *name)

if (name == NULL) {
    return;
}

if (name->instance != NULL) {

    g_free(name->instance);

}
if (name->name != NULL) {

      g_free(name->name);

}

g_slice_free(PlayerctlPlayerName, name);

@acrisci acrisci mentioned this issue May 15, 2020
@acrisci
Copy link
Member

acrisci commented May 15, 2020

I found the issue and was able to recreate it in the testcases. I think c41c479 fixes this.

@acrisci acrisci closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants