match: fix match re-use to use correct match
Make sure we use the *old* match when trying to re-use a match, rather
than the new one.
@@ -266,7 +266,7 @@ int match_rule_new(MatchRule **rulep, MatchOwner *owner, const char *rule_string
slot = c_rbtree_find_slot(&owner->rule_tree, match_rules_compare, &rule->keys, &parent);
if (!slot) {
/* one already exists, take a ref on that instead and drop the one we created */
- *rulep = match_rule_user_ref(rule);
+ *rulep = match_rule_user_ref(c_container_of(parent, MatchRule, owner_node));
} else {
/* link the new rule into the rbtree */
c_rbtree_add(&owner->rule_tree, parent, slot, &rule->owner_node);
