Skip to content
  • Martin Flöser's avatar
    [server] Prevent double delete of callback resources in SurfaceInterface · d1a09838
    Martin Flöser authored
    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
    
    Reviewers: #plasma
    
    Subscribers: plasma-devel
    
    Tags: #plasma
    
    Differential Revision: https://phabricator.kde.org/D1677
    d1a09838