{
yaml_parser_t parser;
char include_filename[PATH_MAX];
- FILE *file;
+ FILE *file = NULL;
+ int ret = -1;
if (yaml_parser_initialize(&parser) != 1) {
SCLogError(SC_ERR_CONF_YAML_ERROR, "Failed to initialize YAML parser");
SCLogError(SC_ERR_FOPEN,
"Failed to open configuration include file %s: %s",
include_filename, strerror(errno));
- return -1;
+ goto done;
}
yaml_parser_set_input_file(&parser, file);
if (ConfYamlParse(&parser, parent, 0) != 0) {
SCLogError(SC_ERR_CONF_YAML_ERROR,
"Failed to include configuration file %s", filename);
- return -1;
+ goto done;
}
+ ret = 0;
+
+done:
yaml_parser_delete(&parser);
- fclose(file);
+ if (file != NULL) {
+ fclose(file);
+ }
- return 0;
+ return ret;
}
/**