Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Fix asan warnings.

Kishore Nallan80641096c959
diff --git a/include/field.h b/include/field.h
index 8d1606e3..b828692b 100644
--- a/include/field.h
+++ b/include/field.h
@@ -736,7 +736,7 @@ struct sort_by {
};
struct eval_t {
- filter_node_t* filter_tree_root;
+ filter_node_t* filter_tree_root = nullptr;
uint32_t* ids = nullptr;
uint32_t size = 0;
};
diff --git a/src/collection.cpp b/src/collection.cpp
index 3831a53a..bc7d40b8 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -27,6 +27,7 @@ struct sort_fields_guard_t {
~sort_fields_guard_t() {
for(auto& sort_by_clause: sort_fields_std) {
+ delete sort_by_clause.eval.filter_tree_root;
if(sort_by_clause.eval.ids) {
delete [] sort_by_clause.eval.ids;
sort_by_clause.eval.ids = nullptr;
@@ -1541,6 +1542,11 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
std::unique_ptr<search_args> search_params_guard(search_params);
auto search_op = index->run_search(search_params, name);
+
+ // filter_tree_root might be updated in Index::static_filter_query_eval.
+ filter_tree_root_guard.release();
+ filter_tree_root_guard.reset(filter_tree_root);
+
if (!search_op.ok()) {
return Option<nlohmann::json>(search_op.code(), search_op.error());
}