Commit 00c7e7b2 authored by Guillaume Quintard's avatar Guillaume Quintard

Protect against use-after-free/unitialized

parent 990857ea
......@@ -136,7 +136,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
static void
wait_stopped(const struct varnish *v)
{
char *r;
char *r = NULL;
enum VCLI_status_e st;
while (1) {
......@@ -150,6 +150,7 @@ wait_stopped(const struct varnish *v)
break;
}
free(r);
r = NULL;
(void)usleep(200000);
}
}
......@@ -160,7 +161,7 @@ wait_stopped(const struct varnish *v)
static void
wait_running(const struct varnish *v)
{
char *r;
char *r = NULL;
enum VCLI_status_e st;
while (1) {
......@@ -180,6 +181,7 @@ wait_running(const struct varnish *v)
break;
}
free(r);
r = NULL;
(void)usleep(200000);
}
}
......@@ -392,7 +394,7 @@ varnish_launch(struct varnish *v)
struct pollfd fd[2];
enum VCLI_status_e u;
const char *err;
char *r;
char *r = NULL;
v->vd = VSM_New();
......@@ -521,6 +523,7 @@ varnish_launch(struct varnish *v)
VCLI_AuthResponse(nfd, r, abuf + 5);
AZ(close(nfd));
free(r);
r = NULL;
strcat(abuf, "\n");
u = varnish_ask_cli(v, abuf, &r);
......@@ -542,7 +545,7 @@ static void
varnish_start(struct varnish *v)
{
enum VCLI_status_e u;
char *resp, *h, *p;
char *resp = NULL, *h, *p;
if (v->cli_fd < 0)
varnish_launch(v);
......@@ -556,6 +559,7 @@ varnish_start(struct varnish *v)
vtc_log(v->vl, 0, "CLI start command failed: %u %s", u, resp);
wait_running(v);
free(resp);
resp = NULL;
u = varnish_ask_cli(v, "debug.xid 999", &resp);
if (vtc_error)
return;
......@@ -563,6 +567,7 @@ varnish_start(struct varnish *v)
vtc_log(v->vl, 0, "CLI debug.xid command failed: %u %s",
u, resp);
free(resp);
resp = NULL;
u = varnish_ask_cli(v, "debug.listen_address", &resp);
if (vtc_error)
return;
......
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