libtreestore

changeset 5:f3ade599cfbb tip

ts_free*/ts_destroy* functions shouldn't bork when passed a null pointer
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 13 Nov 2016 20:40:07 +0200
parents bb873449cf59
children
files src/treestore.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/src/treestore.c	Sun Nov 13 19:46:01 2016 +0200
     1.2 +++ b/src/treestore.c	Sun Nov 13 20:40:07 2016 +0200
     1.3 @@ -382,6 +382,8 @@
     1.4  
     1.5  void ts_destroy_node(struct ts_node *node)
     1.6  {
     1.7 +	if(!node) return;
     1.8 +
     1.9  	free(node->name);
    1.10  
    1.11  	while(node->attr_list) {
    1.12 @@ -409,6 +411,8 @@
    1.13  
    1.14  void ts_free_tree(struct ts_node *tree)
    1.15  {
    1.16 +	if(!tree) return;
    1.17 +
    1.18  	while(tree->child_list) {
    1.19  		struct ts_node *child = tree->child_list;
    1.20  		tree->child_list = tree->child_list->next;