Skip to content

Commit f1c3e3d

Browse files
boxerabtlsa
authored andcommitted
select: prevent double free on static empty_bloom
1 parent c56188d commit f1c3e3d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/select/select.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ static void dump_chain(const css_selector *selector);
137137
#endif
138138

139139

140+
static css_bloom *css__get_empty_bloom(void)
141+
{
142+
static css_bloom empty_bloom[CSS_BLOOM_SIZE];
143+
return empty_bloom;
144+
}
145+
146+
140147
static css_error css__create_node_data(struct css_node_data **node_data)
141148
{
142149
struct css_node_data *nd;
@@ -157,7 +164,8 @@ static void css__destroy_node_data(struct css_node_data *node_data)
157164

158165
assert(node_data != NULL);
159166

160-
if (node_data->bloom != NULL) {
167+
if (node_data->bloom != NULL &&
168+
node_data->bloom != css__get_empty_bloom()) {
161169
free(node_data->bloom);
162170
}
163171

@@ -606,8 +614,7 @@ static css_error css__get_parent_bloom(void *parent,
606614
* by something or not.
607615
* Note, parent bloom is only read from, and not
608616
* written to. */
609-
static css_bloom empty_bloom[CSS_BLOOM_SIZE];
610-
bloom = empty_bloom;
617+
bloom = css__get_empty_bloom();
611618
}
612619
}
613620

0 commit comments

Comments
 (0)