altdesktop / playerctl

🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.
GNU Lesser General Public License v3.0
2.42k stars 79 forks source link

crash on -l #175

Closed J-u-n-o closed 4 years ago

J-u-n-o commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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