Commit 6ca33ca0 authored by Geoff Simmons's avatar Geoff Simmons

Use WS_Copy() for task-scoped .arg() rather than strdup().

parent 4d0710d4
......@@ -672,11 +672,8 @@ task_free(void *p)
struct task_cfg *task;
CAST_OBJ_NOTNULL(task, p, PIPE_TASK_MAGIC);
if (task->argv != NULL) {
for (int i = 1; task->argv[i] != NULL; i++)
free(task->argv[i]);
if (task->argv != NULL)
free(task->argv);
}
}
VCL_VOID
......@@ -720,8 +717,8 @@ vmod_vdp_arg(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING arg)
AN(priv);
if (priv->priv == NULL) {
if ((priv->priv = WS_Alloc(ctx->ws, sizeof(*task))) == NULL) {
VDPFAIL(ctx, "%s.arg(): cannot allocate task config",
obj->name);
VDPFAIL(ctx, "%s.arg(): insufficient workspace for "
"task config", obj->name);
return;
}
task = (struct task_cfg *)priv->priv;
......@@ -732,8 +729,12 @@ vmod_vdp_arg(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING arg)
obj->name, vstrerror(errno));
return;
}
if ((task->argv[1] = WS_Copy(ctx->ws, arg, -1)) == NULL) {
VDPFAIL(ctx, "%s.arg(): insufficient workspace for %s",
obj->name, arg);
return;
}
task->argv[0] = obj->path;
task->argv[1] = strdup(arg);
task->argv[2] = NULL;
task->argc = 2;
task->magic = PIPE_TASK_MAGIC;
......@@ -754,7 +755,11 @@ vmod_vdp_arg(VRT_CTX, struct VPFX(pipe_vdp) *obj, VCL_STRING arg)
vstrerror(errno));
return;
}
task->argv[task->argc] = strdup(arg);
if ((task->argv[task->argc] = WS_Copy(ctx->ws, arg, -1)) == NULL) {
VDPFAIL(ctx, "%s.arg(): insufficient workspace for %s",
obj->name, arg);
return;
}
task->argv[task->argc + 1] = NULL;
task->argc++;
......
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