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) {
if (tree) {
for (int i = 0 ; i < tree->edge_len ; i++ ) {
if (tree->edges[i]) {
r3_edge_free(tree->edges[ i ]);
@ -85,6 +86,7 @@ void r3_tree_free(node * tree) {
zfree(tree);
tree = NULL;
}
}
@ -237,9 +239,11 @@ match_entry * match_entry_createl(char * path, int path_len) {
}
void match_entry_free(match_entry * entry) {
if (entry) {
str_array_free(entry->vars);
zfree(entry);
}
}
@ -385,8 +389,10 @@ route * r3_route_create(char * path) {
}
void r3_route_free(route * route) {
if (route) {
zfree(route);
}
}
route * r3_route_createl(char * path, int path_len) {
route * info = zmalloc(sizeof(route));