diff --git a/CHANGES b/CHANGES index 55eafd9..8dfc771 100644 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,11 @@ 1.3 (2021-XX-XX) - Change versioning from X.Y.Z to Y.Z - - the repository file hierachy has been reorganized (compat/ include/) - - man page has been extended - - large portions of code have been reformatted to adhere to OpenBSD's source + - The repository file hierachy has been reorganized (compat/ include/) + - Man page has been extended + - Large portions of code have been reformatted to adhere to OpenBSD's source file style guide to improve readability. - - refactor: replace two-dimensional array for ASN storage with Red-Black tree + - Refactor: replace two-dimensional array for ASN storage with Red-Black tree + - Reduced memory usage 0.0.9 (2021-08-18) - Fix various memory errors diff --git a/expander.c b/expander.c index da4ac2e..df2be34 100644 --- a/expander.c +++ b/expander.c @@ -446,7 +446,7 @@ bgpq_expander_invalidate_asn(struct bgpq_expander *b, const char *q) sx_report(SX_ERROR, "overflow: %s\n", q); return; } - if (asn >= 4294967295) { + if (asn == 0 || asn >= 4294967295) { sx_report(SX_ERROR, "out of range: %s\n", q); return; } @@ -456,15 +456,10 @@ bgpq_expander_invalidate_asn(struct bgpq_expander *b, const char *q) } find.asn = asn; - res = RB_FIND(asn_tree, &b->asnlist, &find); - if (res == NULL) - return; - - if (RB_REMOVE(asn_tree, &b->asnlist, res) == NULL) { - sx_report(SX_ERROR, "failed to remove: %lu", asn); - return; + if ((res = RB_FIND(asn_tree, &b->asnlist, &find)) == NULL) { + RB_REMOVE(asn_tree, &b->asnlist, res); + free(res); } - } }