aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mds-kbdc/make-tree.c11
-rw-r--r--test-files/mds-kbdc/make-tree/invalid/truncated_mapping2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c
index 26ee0a7..cdfae40 100644
--- a/src/mds-kbdc/make-tree.c
+++ b/src/mds-kbdc/make-tree.c
@@ -901,6 +901,7 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
else if (strchr("\\\"<([0123456789", *line))
{
size_t stack_orig = stack_ptr + 1;
+ char* colon;
#define node supernode
#define inner sequence
NEW_NODE(map, MAP);
@@ -915,10 +916,10 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
stack_ptr--;
*end = prev_end_char;
SKIP_SPACES(line);
- if (*line++ != ':')
+ if (colon = line, *line++ != ':')
{
LEAF;
- continue; /* Not an error in macros. */
+ continue; /* Not an error in functions. */
}
BRANCH(":");
#undef inner
@@ -931,6 +932,12 @@ int parse_to_tree(const char* restrict filename, mds_kbdc_parsed_t* restrict res
#define node supernode
LEAF;
#undef node
+ if (supernode->result == NULL)
+ {
+ NEW_ERROR(1, ERROR, "output missing");
+ error->start = (size_t)(colon - LINE);
+ error->end = error->start + 1;
+ }
if (*line == '\0')
continue;
end = line + strlen(line), prev_end_char = *end;
diff --git a/test-files/mds-kbdc/make-tree/invalid/truncated_mapping b/test-files/mds-kbdc/make-tree/invalid/truncated_mapping
new file mode 100644
index 0000000..b3a89a7
--- /dev/null
+++ b/test-files/mds-kbdc/make-tree/invalid/truncated_mapping
@@ -0,0 +1,2 @@
+<my_key> :
+