[server] Prevent double delete of callback resources in SurfaceInterface
ClosedPublic

Authored by graesslin on May 25 2016, 7:03 AM.

Details

Summary

When destroying a SurfaceInterface all callbacks are getting destroyed.
This used to iterate over the callbacks and performing
wl_resource_destroy on them. This triggered the destroy handler which
removes the resource from the callback list. Which means removing from
the list we are iterating on. This could result in a double delete or
accessing invalid memory.

This change copies all callbacks to a temporary list and clears the
normal lists. So the destroy handler does no longer modify the lists
currently being iterated on.

Test Plan

Added a test case which crashed with previous code

Diff Detail

Repository
R127 KWayland
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 3976.May 25 2016, 7:03 AM
graesslin retitled this revision from to [server] Prevent double delete of callback resources in SurfaceInterface.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptMay 25 2016, 7:03 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
bshah accepted this revision.May 25 2016, 7:11 AM
bshah added a reviewer: bshah.
This revision is now accepted and ready to land.May 25 2016, 7:11 AM
This revision was automatically updated to reflect the committed changes.