https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246596

            Bug ID: 246596
           Summary: Memory leak in ctld
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: b...@freebsd.org
          Reporter: patrykkotlow...@gmail.com

In ucl_parse.c file there is memory leak:

int
uclparse_conf(struct conf *newconf, const char *path)
{
        struct ucl_parser *parser;
        int error; 

        conf = newconf;
        parser = ucl_parser_new(0);

        if (!ucl_parser_add_file(parser, path)) {
                log_warn("unable to parse configuration file %s: %s", path,
                    ucl_parser_get_error(parser));
                return (1);
        }

        error = uclparse_toplevel(ucl_parser_get_object(parser));

        return (error);
}

ucl_parser pointer is never freed. 

My fix proposal is following (I tested it in my production environment):


int
uclparse_conf(struct conf *newconf, const char *path)
{
        struct ucl_parser *parser;
        int error; 

        conf = newconf;
        parser = ucl_parser_new(0);

        if (!ucl_parser_add_file(parser, path)) {
                log_warn("unable to parse configuration file %s: %s", path,
                    ucl_parser_get_error(parser));
                return (1);
        }

        ucl_object_t *p_top = ucl_parser_get_object(parser);
        error = uclparse_toplevel(p_top);

        ucl_object_unref(p_top);
        ucl_parser_free(parser);

        return (error);
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to