diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-05-17 21:04:33 +0100 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-05-17 21:04:33 +0100 |
commit | 764827bdcf1d4188593efa1c5c4e1214f12e3d5e (patch) | |
tree | 7e6b4e5a26add24a76b5c992e380076f6d86cc78 /lib | |
parent | 2aeaa406fd35ae6bf032d467eb20c864c962d30c (diff) | |
download | quagga-764827bdcf1d4188593efa1c5c4e1214f12e3d5e.tar.bz2 quagga-764827bdcf1d4188593efa1c5c4e1214f12e3d5e.tar.xz |
Fix for changing of prefix-list entries.
A bug in vector_move_item_here() meant that under some circumstances
an "ip prefix-list" command would trigger an assert() because updating
an existing entry (with a sequence number) failed to keep the cache
of entries correctly sorted.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vector.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/vector.c b/lib/vector.c index 83f289fe..e03febdc 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -441,11 +441,13 @@ vector_move_item(vector v, vector_index i_dst, vector_index i_src) * * rider < 0 -- move to before the item at the given position * rider == 0 -- move to replace item at the given position - * rider > 0 -- insert after the item at the given position + * rider > 0 -- move to after the item at the given position * * NB: it is the caller's responsibility to release the any existing value * that will be replaced. * + * NB: replacing an item by itself (rider == 0, i_dst == i_src) deletes it ! + * * Move items and extend vector as required. */ void @@ -454,8 +456,17 @@ vector_move_item_here(vector v, vector_index i_dst, int rider, { if (rider != 0) { - if (rider > 0) - ++i_dst ; + if (i_src < i_dst) + { + if (rider < 0) + --i_dst ; /* moving up places src after dst */ + } + else if (i_src > i_dst) + { + if (rider > 0) + ++i_dst ; /* moving down places src before dst */ + } ; + vector_move_item(v, i_dst, i_src) ; } else |