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