diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2019-04-18 12:32:19 -0300 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2019-04-19 16:09:50 -0300 | 
| commit | 6c4c3561fe07a0f388aba938643d8932450f8be1 (patch) | |
| tree | c2dfe94051db85896f9ca87f7743704d31a96f8b /ripngd/ripng_offset.c | |
| parent | c02a40c14fec005d419ad1dbd3fac0e9521b9c6f (diff) | |
ripd, ripngd: fix cleaning up of offset lists
We should never attempt to remove a list item in the "del" callback
of the list. This is already performed by the list_delete() function,
doing it twice leads to crashes or memory corruption.
Introduce the offset_list_free() function so that we can separate the
removal and deallocation of offset lists into separate functions,
without code duplication. offset_list_del() will be used by the
northbound callbacks to remove offset lists, while offset_list_free()
will be used by rip_clean() to clean up all RIP offset lists using
list_delete(). Do the same for ripngd.
This is a fallout from the ripd/ripngd northbound conversion.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd/ripng_offset.c')
| -rw-r--r-- | ripngd/ripng_offset.c | 5 | 
1 files changed, 5 insertions, 0 deletions
diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c index 41ba2360ba..fe95ccfc2b 100644 --- a/ripngd/ripng_offset.c +++ b/ripngd/ripng_offset.c @@ -56,6 +56,11 @@ struct ripng_offset_list *ripng_offset_list_new(struct ripng *ripng,  void ripng_offset_list_del(struct ripng_offset_list *offset)  {  	listnode_delete(offset->ripng->offset_list_master, offset); +	ripng_offset_list_free(offset); +} + +void ripng_offset_list_free(struct ripng_offset_list *offset) +{  	if (OFFSET_LIST_IN_NAME(offset))  		free(OFFSET_LIST_IN_NAME(offset));  	if (OFFSET_LIST_OUT_NAME(offset))  | 
