Skip to content

Commit 010c34b

Browse files
committed
MEDIUM: pattern: consider gen_id in pat_ref_set_from_node()
Don't set all duplicates from a given node if they don't have the same gen_id. Indeed, now we consider the gen_id to only work on the same pattern ref revision.
1 parent 4792f27 commit 010c34b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pattern.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,12 +1805,20 @@ int pat_ref_set_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt, const cha
18051805
static int pat_ref_set_from_node(struct pat_ref *ref, struct ebmb_node *node, const char *value, char **err)
18061806
{
18071807
struct pat_ref_elt *elt;
1808+
unsigned int gen;
1809+
int first = 1;
18081810
int found = 0;
18091811

18101812
while (node) {
18111813
char *tmp_err = NULL;
18121814

18131815
elt = ebmb_entry(node, struct pat_ref_elt, node);
1816+
if (first)
1817+
gen = elt->gen_id;
1818+
else if (elt->gen_id != gen) {
1819+
/* only consider duplicate elements from the same gen! */
1820+
continue;
1821+
}
18141822
node = ebmb_next_dup(node);
18151823
if (!pat_ref_set_elt(ref, elt, value, &tmp_err)) {
18161824
if (err)
@@ -1820,6 +1828,7 @@ static int pat_ref_set_from_node(struct pat_ref *ref, struct ebmb_node *node, co
18201828
return 0;
18211829
}
18221830
found = 1;
1831+
first = 0;
18231832
}
18241833

18251834
if (!found) {

0 commit comments

Comments
 (0)