Skip to content

Commit e61e069

Browse files
authored
Merge pull request #10 from allanjude/merge_error
Do not fail over to parsing input as a string if the error is a merge error
2 parents 2bc8997 + db67b48 commit e61e069

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

uclcmd_parse.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ parse_input(struct ucl_parser *parser, FILE *source)
6868
success = ucl_parser_add_chunk(parser, inbuf, r);
6969
fclose(source);
7070

71+
if (ucl_parser_get_error_code(parser) == UCL_EMERGE) {
72+
fprintf(stderr, "Error: Parse Error occured: %s\n",
73+
ucl_parser_get_error(parser));
74+
cleanup();
75+
exit(3);
76+
}
77+
7178
if (success == false) {
7279
/* There must be a better way to detect a string */
7380
ucl_parser_clear_error(parser);
@@ -95,6 +102,14 @@ parse_string(struct ucl_parser *parser, char *data)
95102
bool success = false;
96103

97104
success = ucl_parser_add_string(parser, data, 0);
105+
106+
if (ucl_parser_get_error_code(parser) == UCL_EMERGE) {
107+
fprintf(stderr, "Error: Parse Error occured: %s\n",
108+
ucl_parser_get_error(parser));
109+
cleanup();
110+
exit(3);
111+
}
112+
98113
if (success == false) {
99114
/* There must be a better way to detect a string */
100115
ucl_parser_clear_error(parser);

0 commit comments

Comments
 (0)