From: Lawrence Teo Date: Fri, 20 Jan 2012 02:43:04 +0000 (-0500) Subject: Plug memory and file descriptor leaks in conf_load(). X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=1bc1f62c7a0ed3edf41faf0cec49cfad2db794b0;p=spectrwm.git Plug memory and file descriptor leaks in conf_load(). From: Tiago Cunha ok marco --- diff --git a/scrotwm.c b/scrotwm.c index cb56f65..0c339a2 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -5400,7 +5400,7 @@ conf_load(char *filename, int keymapping) if (wordlen == 0) { warnx("%s: line %zd: no option found", filename, lineno); - return (1); + goto out; } optind = -1; for (i = 0; i < LENGTH(configopt); i++) { @@ -5414,12 +5414,12 @@ conf_load(char *filename, int keymapping) if (optind == -1) { warnx("%s: line %zd: unknown option %.*s", filename, lineno, wordlen, cp); - return (1); + goto out; } if (keymapping && strcmp(opt->optname, "bind")) { warnx("%s: line %zd: invalid option %.*s", filename, lineno, wordlen, cp); - return (1); + goto out; } cp += wordlen; cp += strspn(cp, " \t\n"); /* eat whitespace */ @@ -5432,7 +5432,7 @@ conf_load(char *filename, int keymapping) if (wordlen == 0) { warnx("%s: line %zd: syntax error", filename, lineno); - return (1); + goto out; } asprintf(&optsub, "%.*s", wordlen, cp); } @@ -5459,6 +5459,12 @@ conf_load(char *filename, int keymapping) DNPRINTF(SWM_D_CONF, "conf_load end\n"); return (0); + +out: + free(line); + fclose(config); + + return (1); } void