From 6be60a6de4d0fa4bfa8e2bbba89e58bf4de27e71 Mon Sep 17 00:00:00 2001 From: Adam Greenwood-Byrne Date: Mon, 19 Apr 2021 18:30:07 +0100 Subject: [PATCH] Zero buffer in wgtprintf properly --- part12-wgt/wgt/wgtprn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/part12-wgt/wgt/wgtprn.c b/part12-wgt/wgt/wgtprn.c index 80445c7..8830960 100644 --- a/part12-wgt/wgt/wgtprn.c +++ b/part12-wgt/wgt/wgtprn.c @@ -428,12 +428,16 @@ number: void wgtprintf (short x, short y, wgtfont font, const char *fmt, ...) { + char *buffer = malloc(250); /* Buffer to build string into*/ + memset(buffer, 0, 250); + va_list ap; va_start(ap, fmt); - char buffer[251]; /* Buffer to build string into*/ kvprintf(fmt, NULL, (void *)buffer, 10, ap); wouttextxy (x, y, font, buffer); va_end(ap); + + free(buffer); }