Commit 1c137872 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't leak a filename in error exits, it upsets Coverity.

parent 1f1d4872
...@@ -534,6 +534,7 @@ vcc_file_source(const struct vcp * const vcp, struct vsb *sb, const char *fn) ...@@ -534,6 +534,7 @@ vcc_file_source(const struct vcp * const vcp, struct vsb *sb, const char *fn)
if (VFIL_searchpath(vcp->vcl_path, NULL, &f, fn, &fnp) || f == NULL) { if (VFIL_searchpath(vcp->vcl_path, NULL, &f, fn, &fnp) || f == NULL) {
VSB_printf(sb, "Cannot read file '%s' (%s)\n", VSB_printf(sb, "Cannot read file '%s' (%s)\n",
fnp != NULL ? fnp : fn, strerror(errno)); fnp != NULL ? fnp : fn, strerror(errno));
REPLACE(fnp, NULL);
return (NULL); return (NULL);
} }
sp = vcc_new_source(f, NULL, fnp); sp = vcc_new_source(f, NULL, fnp);
......
...@@ -61,7 +61,7 @@ void ...@@ -61,7 +61,7 @@ void
vcc_ParseImport(struct vcc *tl) vcc_ParseImport(struct vcc *tl)
{ {
void *hdl; void *hdl;
char fn[1024], *fnp; char fn[1024], *fnp, *fnpx;
char buf[256]; char buf[256];
struct token *mod, *t1; struct token *mod, *t1;
struct inifin *ifp; struct inifin *ifp;
...@@ -130,14 +130,19 @@ vcc_ParseImport(struct vcc *tl) ...@@ -130,14 +130,19 @@ vcc_ParseImport(struct vcc *tl)
SkipToken(tl, ';'); SkipToken(tl, ';');
if (VFIL_searchpath(tl->param->vmod_path, if (VFIL_searchpath(tl->param->vmod_path,
vcc_path_dlopen, &hdl, fn, &fnp)) { vcc_path_dlopen, &hdl, fn, &fnpx)) {
VSB_printf(tl->sb, "Could not load VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "Could not load VMOD %.*s\n", PF(mod));
VSB_printf(tl->sb, "\tFile name: %s\n", fnp != NULL ? fnp : fn); VSB_printf(tl->sb, "\tFile name: %s\n",
fnpx != NULL ? fnpx : fn);
VSB_printf(tl->sb, "\tdlerror: %s\n", dlerror()); VSB_printf(tl->sb, "\tdlerror: %s\n", dlerror());
vcc_ErrWhere(tl, mod); vcc_ErrWhere(tl, mod);
REPLACE(fnpx, NULL);
return; return;
} }
fnp = TlDup(tl, fnpx);
REPLACE(fnpx, NULL);
bprintf(buf, "Vmod_%.*s_Data", PF(mod)); bprintf(buf, "Vmod_%.*s_Data", PF(mod));
vmd = dlsym(hdl, buf); vmd = dlsym(hdl, buf);
if (vmd == NULL) { if (vmd == NULL) {
...@@ -195,7 +200,6 @@ vcc_ParseImport(struct vcc *tl) ...@@ -195,7 +200,6 @@ vcc_ParseImport(struct vcc *tl)
VSB_printf(ifp->ini, "\t \"%.*s\",\n", PF(mod)); VSB_printf(ifp->ini, "\t \"%.*s\",\n", PF(mod));
VSB_printf(ifp->ini, "\t "); VSB_printf(ifp->ini, "\t ");
EncString(ifp->ini, fnp, NULL, 0); EncString(ifp->ini, fnp, NULL, 0);
free(fnp);
VSB_printf(ifp->ini, ",\n"); VSB_printf(ifp->ini, ",\n");
AN(vmd); AN(vmd);
AN(vmd->file_id); AN(vmd->file_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment