Guarding against freeing NULL pointers.

This commit is contained in:
Omer Katz 2014-05-21 12:46:56 +03:00
parent 3ea9354e0b
commit 61b3b24e2e

View file

@ -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 ]);
@ -84,6 +85,7 @@ void r3_tree_free(node * tree) {
zfree(tree->ov); zfree(tree->ov);
zfree(tree); zfree(tree);
tree = NULL; tree = NULL;
}
} }
@ -237,8 +239,10 @@ 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,7 +389,9 @@ 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) {