diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 14fa7dafee48..a13d1ebb3529 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -267,7 +267,8 @@ include(const char *fname, int ateof) asprintf(&fnamebuf, "../../conf/%s", fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); - free(fnamebuf); + if (fp == NULL) + free(fnamebuf); } } if (fp == NULL) { @@ -275,10 +276,10 @@ include(const char *fname, int ateof) asprintf(&fnamebuf, "%s/%s", ipath->path, fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); - free(fnamebuf); } if (fp != NULL) break; + free(fnamebuf); } } if (fp == NULL) {