Commit changes are made to avoid possible memory leaks. If the parser
is initialized before configuration file checking, there was no deinit
call before function return. Do check config file existance and type
before YAML parser initialization, so we don't need to deinit parser
before exiting the function.
Bug: #7302
(cherry picked from commit
87e6e9374ff40847d3e7408afcd404374b629337)
int ret;
ConfNode *root = ConfGetNode(prefix);
- if (yaml_parser_initialize(&parser) != 1) {
- SCLogError("failed to initialize yaml parser.");
- return -1;
- }
-
struct stat stat_buf;
/* coverity[toctou] */
if (stat(filename, &stat_buf) == 0) {
}
}
+ if (yaml_parser_initialize(&parser) != 1) {
+ SCLogError("failed to initialize yaml parser.");
+ return -1;
+ }
+
/* coverity[toctou] */
infile = fopen(filename, "r");
if (infile == NULL) {