Skip to content

Commit faf25ee

Browse files
committed
fix(config): drop the fuzz-link and Cypher hunks from the worktree change
The review of 2026-10-01 asked to split these out of the ignore_worktrees change. Neither belongs to it, and both are already on main in another form, so this restores the three files to the branch merge-base: - Makefile.cbm: main links cbm-fuzz with -fsanitize-link-c++-runtime. - src/cypher/cypher.c and tests/test_cypher.c: main frees a partially parsed MATCH pattern since 70543ba, with its own regression test cypher_parse_error_frees_partial_pattern. Signed-off-by: Martin Vogel <[email protected]>
1 parent 62479ff commit faf25ee

3 files changed

Lines changed: 10 additions & 38 deletions

File tree

‎Makefile.cbm‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,10 +1381,10 @@ fuzz:
13811381
CC=$(FUZZ_CC) CXX=$(FUZZ_CXX) SANITIZE="$(FUZZ_SANITIZE)"
13821382

13831383
$(BUILD_DIR)/cbm-fuzz: $(FUZZ_SRC) $(PROD_SRCS) $(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) $(OBJS_VENDORED_TEST) $(PROJECT_HDRS) | $(BUILD_DIR)
1384-
$(CXX) $(CFLAGS_TEST) -x c -fsanitize=fuzzer -o $@ \
1384+
$(CC) $(CFLAGS_TEST) -fsanitize=fuzzer -o $@ \
13851385
$(FUZZ_SRC) $(PROD_SRCS) \
13861386
$(EXTRACTION_SRCS) $(AC_LZ4_SRCS) $(ZSTD_SRCS) $(SQLITE_WRITER_SRC) \
1387-
-x none $(OBJS_VENDORED_TEST) \
1387+
$(OBJS_VENDORED_TEST) \
13881388
$(LDFLAGS_TEST)
13891389

13901390
# Path-sensitive memory analysis: leak paths, null derefs, uninitialized reads.

‎src/cypher/cypher.c‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,8 +1862,6 @@ static int parse_return(parser_t *p, cbm_return_clause_t **out) {
18621862
return parse_return_or_with(p, out, false);
18631863
}
18641864

1865-
static void free_pattern(cbm_pattern_t *pat);
1866-
18671865
/* Parse a single MATCH pattern into pat */
18681866
static int parse_match_pattern(parser_t *p, cbm_pattern_t *pat) {
18691867
memset(pat, 0, sizeof(*pat));
@@ -1872,38 +1870,31 @@ static int parse_match_pattern(parser_t *p, cbm_pattern_t *pat) {
18721870
pat->nodes = malloc(node_cap * sizeof(cbm_node_pattern_t));
18731871
pat->rels = calloc(rel_cap, sizeof(cbm_rel_pattern_t));
18741872

1875-
/* Count the slot before parsing so even partially filled nodes and
1876-
* relationships are released when a malformed pattern is rejected. */
1877-
pat->node_count = SKIP_ONE;
18781873
if (parse_node(p, &pat->nodes[0]) < 0) {
1879-
goto fail;
1874+
return CBM_NOT_FOUND;
18801875
}
1876+
pat->node_count = SKIP_ONE;
18811877

18821878
while (check(p, TOK_DASH) || check(p, TOK_LT)) {
18831879
if (pat->rel_count >= rel_cap) {
18841880
rel_cap *= PAIR_LEN;
18851881
pat->rels = safe_realloc(pat->rels, rel_cap * sizeof(cbm_rel_pattern_t));
18861882
}
1887-
pat->rel_count++;
1888-
if (parse_rel(p, &pat->rels[pat->rel_count - SKIP_ONE]) < 0) {
1889-
goto fail;
1883+
if (parse_rel(p, &pat->rels[pat->rel_count]) < 0) {
1884+
return CBM_NOT_FOUND;
18901885
}
1886+
pat->rel_count++;
18911887

18921888
if (pat->node_count >= node_cap) {
18931889
node_cap *= PAIR_LEN;
18941890
pat->nodes = safe_realloc(pat->nodes, node_cap * sizeof(cbm_node_pattern_t));
18951891
}
1896-
pat->node_count++;
1897-
if (parse_node(p, &pat->nodes[pat->node_count - SKIP_ONE]) < 0) {
1898-
goto fail;
1892+
if (parse_node(p, &pat->nodes[pat->node_count]) < 0) {
1893+
return CBM_NOT_FOUND;
18991894
}
1895+
pat->node_count++;
19001896
}
19011897
return 0;
1902-
1903-
fail:
1904-
free_pattern(pat);
1905-
memset(pat, 0, sizeof(*pat));
1906-
return CBM_NOT_FOUND;
19071898
}
19081899

19091900
/* Parse UNWIND [...] AS var clause into query */

‎tests/test_cypher.c‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,6 @@ TEST(cypher_parse_accepts_single_with_clause) {
274274
PASS();
275275
}
276276

277-
TEST(cypher_parse_rejects_partial_patterns) {
278-
const char *queries[] = {
279-
"MATCH p = (a:Class)-[:INHERITS*1..3]->(b:Class) RETURN a.name, length(p)",
280-
"MATCH (a)-[:CALLS]->(b) MATCH (c)-[:CALLS*]-> RETURN a.name",
281-
"MATCH (a)-[:CALLS|]->(b)",
282-
};
283-
for (size_t i = 0; i < sizeof(queries) / sizeof(queries[0]); i++) {
284-
cbm_query_t *q = NULL;
285-
char *err = NULL;
286-
int rc = cbm_cypher_parse(queries[i], &q, &err);
287-
ASSERT_NEQ(rc, 0);
288-
ASSERT_NULL(q);
289-
ASSERT_NOT_NULL(err);
290-
free(err);
291-
}
292-
PASS();
293-
}
294-
295277
TEST(cypher_parse_relationship_outbound) {
296278
cbm_query_t *q = NULL;
297279
char *err = NULL;
@@ -4860,7 +4842,6 @@ SUITE(cypher) {
48604842
RUN_TEST(cypher_parse_rejects_trailing_tokens);
48614843
RUN_TEST(cypher_parse_rejects_second_with_clause);
48624844
RUN_TEST(cypher_parse_accepts_single_with_clause);
4863-
RUN_TEST(cypher_parse_rejects_partial_patterns);
48644845
RUN_TEST(cypher_parse_relationship_outbound);
48654846
RUN_TEST(cypher_parse_relationship_inbound);
48664847
RUN_TEST(cypher_parse_relationship_any);

0 commit comments

Comments
 (0)