Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(store): reject null search handles
Martin Vogel37880b62e854
diff --git a/src/store/store.c b/src/store/store.cindex 55581c254..df08da0c8 100644--- a/src/store/store.c+++ b/src/store/store.c@@ -1459,6 +1459,11 @@ static int find_nodes_generic(cbm_store_t *s, sqlite3_stmt **slot, const char *sint cbm_store_find_nodes_by_name(cbm_store_t *s, const char *project, const char *name,cbm_node_t **out, int *count) {+ if (!s) {+ *out = NULL;+ *count = 0;+ return CBM_STORE_ERR;+ }return find_nodes_generic(s, &s->stmt_find_nodes_by_name,"SELECT id, project, label, name, qualified_name, file_path, ""start_line, end_line, properties FROM nodes "@@ -1468,6 +1473,11 @@ int cbm_store_find_nodes_by_name(cbm_store_t *s, const char *project, const charint cbm_store_find_nodes_by_label(cbm_store_t *s, const char *project, const char *label,cbm_node_t **out, int *count) {+ if (!s) {+ *out = NULL;+ *count = 0;+ return CBM_STORE_ERR;+ }return find_nodes_generic(s, &s->stmt_find_nodes_by_label,"SELECT id, project, label, name, qualified_name, file_path, ""start_line, end_line, properties FROM nodes "@@ -1477,6 +1487,11 @@ int cbm_store_find_nodes_by_label(cbm_store_t *s, const char *project, const chaint cbm_store_find_nodes_by_file(cbm_store_t *s, const char *project, const char *file_path,cbm_node_t **out, int *count) {+ if (!s) {+ *out = NULL;+ *count = 0;+ return CBM_STORE_ERR;+ }return find_nodes_generic(s, &s->stmt_find_nodes_by_file,"SELECT id, project, label, name, qualified_name, file_path, ""start_line, end_line, properties FROM nodes "diff --git a/tests/test_store_search.c b/tests/test_store_search.cindex 5cbf1a199..2eb189ed5 100644--- a/tests/test_store_search.c+++ b/tests/test_store_search.c@@ -7,6 +7,7 @@#include "test_framework.h"#include "test_helpers.h"#include <store/store.h>+#include <stdint.h>#include <string.h>#include <stdlib.h>#include <unistd.h>@@ -1458,6 +1459,27 @@ TEST(store_impact_summary_empty) {PASS();}+TEST(store_find_nodes_rejects_null_store_without_ub) {+ cbm_node_t *nodes = (cbm_node_t *)(uintptr_t)1U;+ int count = -1;+ ASSERT_EQ(cbm_store_find_nodes_by_name(NULL, "project", "name", &nodes, &count), CBM_STORE_ERR);+ ASSERT_NULL(nodes);+ ASSERT_EQ(count, 0);+ nodes = (cbm_node_t *)(uintptr_t)1U;+ count = -1;+ ASSERT_EQ(cbm_store_find_nodes_by_label(NULL, "project", "Function", &nodes, &count),+ CBM_STORE_ERR);+ ASSERT_NULL(nodes);+ ASSERT_EQ(count, 0);+ nodes = (cbm_node_t *)(uintptr_t)1U;+ count = -1;+ ASSERT_EQ(cbm_store_find_nodes_by_file(NULL, "project", "file.c", &nodes, &count),+ CBM_STORE_ERR);+ ASSERT_NULL(nodes);+ ASSERT_EQ(count, 0);+ PASS();+}+SUITE(store_search) {RUN_TEST(store_search_by_label);RUN_TEST(store_search_by_name_pattern);@@ -1525,4 +1547,5 @@ SUITE(store_search) {RUN_TEST(store_hop_to_risk_all_levels);RUN_TEST(store_risk_label_all_levels);RUN_TEST(store_impact_summary_empty);+ RUN_TEST(store_find_nodes_rejects_null_store_without_ub);}