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

When a VCL subroutine does not terminate in an action, the compiled code

needs to explicitly set a return value of zero to say so.

Possibly fix for: #339



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3236 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 80bb8a10
# $Id$
test "Check function calls with no action return"
server s1 {
rxreq
expect req.url == "/"
expect req.http.foobar == "snafu"
txresp -body "slash"
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
call some_subr;
}
sub some_subr {
set req.http.foobar = "snafu";
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
......@@ -526,22 +526,31 @@ Function(struct tokenlist *tl)
vcc_AddRef(tl, tl->t, R_FUNC);
}
tl->curproc = tl->mprocs[m];
Fb(tl, 1, " /* ... from ");
vcc_Coord(tl, tl->fb, NULL);
Fb(tl, 0, " */\n");
} else {
tl->fb = tl->fc;
tl->curproc = vcc_AddProc(tl, tl->t);
vcc_AddDef(tl, tl->t, R_FUNC);
Fh(tl, 0, "static int VGC_function_%.*s (struct sess *sp);\n",
PF(tl->t));
Fc(tl, 1, "static int\n");
Fc(tl, 1, "\nstatic int\n");
Fc(tl, 1, "VGC_function_%.*s (struct sess *sp)\n", PF(tl->t));
}
vcc_NextToken(tl);
tl->indent += INDENT;
Fb(tl, 1, "{\n");
L(tl, Compound(tl));
if (m == -1) {
/*
* non-method subroutines must have an explicit non-action
* return in case they just fall through the bottom.
*/
Fb(tl, 1, " return(0);\n");
}
Fb(tl, 1, "}\n");
tl->indent -= INDENT;
Fb(tl, 0, "\n");
tl->fb = NULL;
tl->curproc = NULL;
}
......
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