From 8d33fa030d308e6f5a4572a5b25bde4508757c31 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 11 Jul 2020 15:33:55 -0700 Subject: [PATCH] zero out the result of a vmnewof() This is the only instance of a call to vmnewof() that appears to rely on the semantics of the returned memory having been zeroed. We are about to make some changes that make it impossible for the allocator to zero extra memory in a vmresize() because it does not know the size of the original allocation. This change makes it safe for vmresize() to stop providing zeroed out extra memory. --- lib/expr/exeval.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/expr/exeval.c b/lib/expr/exeval.c index a9e1dab84..2069a612e 100644 --- a/lib/expr/exeval.c +++ b/lib/expr/exeval.c @@ -482,6 +482,7 @@ scformat(Sfio_t* sp, void* vp, Sffmt_t* dp) node->data.variable.symbol->value->data.constant.value.string = 0; fmt->fmt.size = 1024; *((void**)vp) = node->data.variable.symbol->value->data.constant.value.string = vmnewof(fmt->expr->vm, node->data.variable.symbol->value->data.constant.value.string, char, fmt->fmt.size, 0); + memset(node->data.variable.symbol->value->data.constant.value.string, 0, sizeof(char) * (size_t)fmt->fmt.size); break; case 'c': if (node->type != CHARACTER) { -- 2.40.0