Commit bdcdc921 authored by Nils Goroll's avatar Nils Goroll

Handle VRT_priv_task errors gracefully

The reason is the same as for
https://github.com/varnishcache/varnish-cache/issues/2708 :

VRT_priv_task may now return NULL for out-of-workspace errors, see
https://github.com/varnishcache/varnish-cache/commit/de2b431086a13b243dc8b3e71cd8697db1df2c7f
parent a83014a0
......@@ -348,7 +348,10 @@ vmod_set_match(VRT_CTX, struct vmod_re2_set *set, VCL_STRING subject)
}
priv = VRT_priv_task(ctx, set);
AN(priv);
if (priv == NULL) {
ERR(ctx, "No priv_task - workspace overflow?");
return 0;
}
if (priv->priv == NULL) {
if ((priv->priv = WS_Alloc(ctx->ws, sizeof(*task))) == NULL) {
VERRNOMEM(ctx, ERR_PREFIX "allocating match data",
......@@ -408,8 +411,7 @@ get_task_data(VRT_CTX, struct vmod_re2_set *set)
struct task_set_match *task;
priv = VRT_priv_task(ctx, set);
AN(priv);
if (priv->priv == NULL)
if (priv == NULL || priv->priv == NULL)
return NULL;
WS_Assert_Allocated(ctx->ws, priv->priv, sizeof(*task));
CAST_OBJ(task, priv->priv, TASK_SET_MATCH_MAGIC);
......
......@@ -301,7 +301,10 @@ vmod_regex_match(const struct vrt_ctx *ctx, struct vmod_re2_regex *re,
CHECK_OBJ_NOTNULL(re, VMOD_RE2_REGEX_MAGIC);
task = VRT_priv_task(ctx, re);
AN(task);
if (task == NULL) {
ERR(ctx, "No priv_task - workspace overflow?");
return 0;
}
if (task->priv == NULL) {
if ((task->priv = WS_Alloc(ctx->ws, sizeof(*task_match)))
== NULL) {
......@@ -355,7 +358,10 @@ vmod_regex_backref(VRT_CTX, struct vmod_re2_regex *re, VCL_INT refnum,
}
task = VRT_priv_task(ctx, re);
AN(task);
if (task == NULL) {
ERR(ctx, "No priv_task - workspace overflow?");
return 0;
}
if (task->priv == NULL) {
VERR(ctx, ERR_PREFIX "backref called without prior match",
re->vcl_name, refnum, fallback);
......@@ -396,7 +402,10 @@ vmod_regex_namedref(VRT_CTX, struct vmod_re2_regex *re, VCL_STRING name,
}
task = VRT_priv_task(ctx, re);
AN(task);
if (task == NULL) {
ERR(ctx, "No priv_task - workspace overflow?");
return 0;
}
if (task->priv == NULL) {
VERR(ctx, ERR_PREFIX "namedref called without prior match",
re->vcl_name, name, fallback);
......
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