From 29e2dd7a23b2246683d2f182fc945160075d7707 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 16 Dec 2020 18:41:31 +0100 Subject: [PATCH] btrfs-progs: initialize formatter context properly In cases where the compiler does not initialize the formatter context to all zeros, there could be garbage values left on the depth 0 that is not explicitly initialized. This could lead to mistakenly printing a "," separator before the last closing "}", like { "__header": { "version": "1" }, } Signed-off-by: David Sterba --- common/format-output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/format-output.c b/common/format-output.c index ac68a7fa..f5b12548 100644 --- a/common/format-output.c +++ b/common/format-output.c @@ -98,6 +98,7 @@ static void fmt_separator(struct format_ctx *fctx) void fmt_start(struct format_ctx *fctx, const struct rowspec *spec, int width, int indent) { + memset(fctx, 0, sizeof(*fctx)); fctx->width = width; fctx->indent = indent; fctx->rowspec = spec;