]> git.puffer.fish Git - mirror/frr.git/commit
lib: graph: fix deletions
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 25 Jan 2017 03:13:14 +0000 (04:13 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 26 Jan 2017 06:05:21 +0000 (07:05 +0100)
commit72d98ee94360a5da0af76d8e800a72c8d51c48b5
treec3477667153d1d138518eb63eea83a0afd669bc1
parent1e78204400361625235b3e7ea5d2c570b16d7c55
lib: graph: fix deletions

Iterating over an array while deleting items needs to consider
interactions between the iteration position and deletion.  The previous
code completely ignored that problem, leading to memleaks (graph_delete
skipping half of the nodes) and dangling pointers (if parallel edges
exist in graph_remove_edge).

Iterating backwards is safe and reduces "move to fill hole" overhead in
deletion.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Quentin Young <qlyoung@cumulusnetworks.com>
lib/graph.c