# HG changeset patch # User reimar # Date 1352239526 0 # Node ID 2d529504ec2d3b5e18e12ad822e7c14e975f02cb # Parent 8756cd0da7b707b44ba6862c40bdac517c1463ec Properly free resources even when encountering many parse errors. diff -r 8756cd0da7b7 -r 2d529504ec2d parser-cfg.c --- a/parser-cfg.c Tue Nov 06 21:59:59 2012 +0000 +++ b/parser-cfg.c Tue Nov 06 22:05:26 2012 +0000 @@ -59,8 +59,8 @@ #define MAX_LINE_LEN 10000 #define MAX_OPT_LEN 1000 #define MAX_PARAM_LEN 1500 - FILE *fp; - char *line; + FILE *fp = NULL; + char *line = NULL; char opt[MAX_OPT_LEN + 1]; char param[MAX_PARAM_LEN + 1]; char c; /* for the "" and '' check */ @@ -98,7 +98,6 @@ if ((fp = fopen(conffile, "r")) == NULL) { mp_msg(MSGT_CFGPARSER,silent?MSGL_V:MSGL_ERR,"Failed to read %s: %s\n", conffile, strerror(errno)); - free(line); ret = silent ? 0 : -1; goto out; } @@ -255,9 +254,9 @@ ; } +out: free(line); - fclose(fp); -out: + if (fp) fclose(fp); config->mode = prev_mode; --recursion_depth; return ret;