Skip to content
  • Fabrice Bellet's avatar
    component: Fix use-after-free and resolve regression · 71a8a9e2
    Fabrice Bellet authored and Olivier Crête's avatar Olivier Crête committed
    conn_check_prune_socket() on nsocket must be called before removing the
    candidate with this socket inside the loop, to prevent the
    use-after-free reported initially in issue #73.
    
    But commit 541801d4 introduced a regression during discovery when an udp
    turn over tcp socket is immediately closed by a HUP condition for
    example. In this case, discovery_prune_socket() is never called, because
    we don't have a candidate with this socket inside the loop. So the
    nsocket is freed by the final nice_component_detach_socket() but is
    still used by the discovery timer callback.
    
    This commit moves the discovery_prune_socket() and
    conn_check_prune_socket() actions before the loop instead of after, or
    inside.
    
    Closes #73
    71a8a9e2