Guarding against freeing NULL pointers.
This commit is contained in:
parent
3ea9354e0b
commit
61b3b24e2e
1 changed files with 26 additions and 20 deletions
|
@ -65,6 +65,7 @@ node * r3_tree_create(int cap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void r3_tree_free(node * tree) {
|
void r3_tree_free(node * tree) {
|
||||||
|
if (tree) {
|
||||||
for (int i = 0 ; i < tree->edge_len ; i++ ) {
|
for (int i = 0 ; i < tree->edge_len ; i++ ) {
|
||||||
if (tree->edges[i]) {
|
if (tree->edges[i]) {
|
||||||
r3_edge_free(tree->edges[ i ]);
|
r3_edge_free(tree->edges[ i ]);
|
||||||
|
@ -85,6 +86,7 @@ void r3_tree_free(node * tree) {
|
||||||
zfree(tree);
|
zfree(tree);
|
||||||
tree = NULL;
|
tree = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,9 +239,11 @@ match_entry * match_entry_createl(char * path, int path_len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void match_entry_free(match_entry * entry) {
|
void match_entry_free(match_entry * entry) {
|
||||||
|
if (entry) {
|
||||||
str_array_free(entry->vars);
|
str_array_free(entry->vars);
|
||||||
zfree(entry);
|
zfree(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,8 +389,10 @@ route * r3_route_create(char * path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void r3_route_free(route * route) {
|
void r3_route_free(route * route) {
|
||||||
|
if (route) {
|
||||||
zfree(route);
|
zfree(route);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route * r3_route_createl(char * path, int path_len) {
|
route * r3_route_createl(char * path, int path_len) {
|
||||||
route * info = zmalloc(sizeof(route));
|
route * info = zmalloc(sizeof(route));
|
||||||
|
|
Loading…
Reference in a new issue