playerctl icon indicating copy to clipboard operation
playerctl copied to clipboard

fix: Checks if message body is NULL before getting number of children.

Open 5061726b6572 opened this issue 10 months ago • 2 comments

Fixes segmentation fault from calling g_variant_n_children on NULL GVariant*. The body returned by g_dbus_message_get_body can be NULL (https://docs.gtk.org/gio/method.DBusMessage.get_body.html) which is not accounted for in current error handling code.

Thread 1 "playerctld" received signal SIGSEGV, Segmentation fault.
g_bit_lock (address=0x30, lock_bit=0) at ../glib/glib/gbitlock.c:219
219	 __asm__ volatile goto ("lock bts %1, (%0)\n"
(gdb) bt
#0  g_bit_lock (address=0x30, lock_bit=0) at ../glib/glib/gbitlock.c:219
#1  0x00007ffff7e96c93 in g_variant_lock (value=0x0) at ../glib/glib/gvariant-core.c:263
#2  g_variant_n_children (value=0x0) at ../glib/glib/gvariant-core.c:1102
#3  0x000055555555984f in proxy_method_call_async_callback
    (source_object=0x555555568d80 [GDBusConnection], res=0x555555588340, user_data=0x7fffec00dad0)
    at ../playerctl/playerctl-daemon.c:741
#4  0x00007ffff7cc64cc in g_task_return_now (task=0x555555588340 [GTask]) at ../glib/gio/gtask.c:1361
#5  0x00007ffff7cc6515 in complete_in_idle_cb (task=0x555555588340) at ../glib/gio/gtask.c:1375
#6  0x00007ffff7e49559 in g_main_dispatch (context=0x5555555770b0) at ../glib/glib/gmain.c:3357
#7  0x00007ffff7eac257 in g_main_context_dispatch_unlocked (context=0x5555555770b0)
    at ../glib/glib/gmain.c:4208
#8  g_main_context_iterate_unlocked.isra.0
    (context=0x5555555770b0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/glib/gmain.c:4273
#9  0x00007ffff7e4a287 in g_main_loop_run (loop=0x55555557e950) at ../glib/glib/gmain.c:4475
#10 0x000055555555c2cc in main (argc=1, argv=0x7fffffffe1d8) at ../playerctl/playerctl-daemon.c:1525

Probably Fixes:

  • #339
  • #268

5061726b6572 avatar Feb 22 '25 04:02 5061726b6572

This fixes https://github.com/altdesktop/playerctl/issues/339 for me.

ncfavier avatar Sep 12 '25 16:09 ncfavier

Ran into the same problem, is there any chance that this is going to be reviewed soon?

faye2go avatar Sep 25 '25 15:09 faye2go