Skip to content

wayland: avoid referencing unallocated memory when uninhibiting

Michael Terry requested to merge mterry/gtk:wayland-inhbit0 into master

gtk_application_impl_wayland_inhibit is allocating a data struct GtkApplicationWaylandInhibitor but not zeroing out a pointer (inhibitor->surface) that it does not necessarily set. Then later, when gtk_application_impl_wayland_uninhibit is called, it tries to dereference that pointer to ill effect.

I've chosen to use g_slice_new0 rather than setting inhibitor->surface = NULL specifically, just because it felt more foolproof down the line. But if that's not the standard style, let me know and I can change. I notice that the quartz and dbus gtkapplication backends do similar non-zeroed allocations, so maybe new0 is avoided for performance reasons? (but in those cases, all struct fields are set, so no problem)

Merge request reports