Subject: | Incorrect returned pointer type |
Date: | Tue, 10 May 2016 14:14:50 -0400 |
To: | bug-Net-Patricia [...] rt.cpan.org |
From: | Richard Bross <rbross [...] dyn.com> |
Nice implementation. In the source code, patricia.c, in the function
patricia_node_t * try_search_best (patricia_tree_t *tree, char *string)
The return type as can be seen is "patricia_node_t *". However, the
following code is at the end of the function:
Deref_Prefix (prefix);
return (prefix);
}
"prefix" is of type "prefix_t *".
This works because C is not strict about the return type, so the
compiler doesn't complain. But any caller who expects a
"patricia_node_t *" and attempts to dereference a member will risks a
segfault or worse.
Thanks,
Rick Bross