fix route appending bug reported by @othree
This commit is contained in:
parent
594d5361dd
commit
03b5d107cd
1 changed files with 13 additions and 7 deletions
20
src/node.c
20
src/node.c
|
@ -714,17 +714,23 @@ node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route
|
||||||
} else {
|
} else {
|
||||||
// there are no more path to insert
|
// there are no more path to insert
|
||||||
|
|
||||||
// see if there is an endpoint already
|
// see if there is an endpoint already, we should n't overwrite the data on child.
|
||||||
if (e->child->endpoint > 0) {
|
// but we still need to append the route.
|
||||||
// XXX: return an error code instead of NULL
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
e->child->endpoint++; // make it as an endpoint
|
|
||||||
e->child->data = data;
|
|
||||||
if (route) {
|
if (route) {
|
||||||
route->data = data;
|
route->data = data;
|
||||||
r3_node_append_route(e->child, route);
|
r3_node_append_route(e->child, route);
|
||||||
|
e->child->endpoint++; // make it as an endpoint
|
||||||
|
return e->child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insertion without route
|
||||||
|
if (e->child->endpoint > 0) {
|
||||||
|
// TODO: return an error code instead of NULL
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
e->child->endpoint++; // make it as an endpoint
|
||||||
|
e->child->data = data; // set data
|
||||||
return e->child;
|
return e->child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue