From c90187046a01c5144d80c2c9d52d7c8e36f24b5b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 14:26:33 -0400 Subject: [PATCH] Zero-fill pkguiAlloc()'s output. --- pkgui.h | 1 + util.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgui.h b/pkgui.h index d511041..d7cd5b2 100644 --- a/pkgui.h +++ b/pkgui.h @@ -3,6 +3,7 @@ #define pkguiHFileIncluded #include +#include #include #include "ui.h" diff --git a/util.go b/util.go index e7fb937..9c3fd63 100644 --- a/util.go +++ b/util.go @@ -12,8 +12,10 @@ import "C" //export pkguiAlloc func pkguiAlloc(n C.size_t) unsafe.Pointer { // cgo turns C.malloc() into a panic-on-OOM version; use it - // TODO make sure it zero-initializes too - return C.malloc(n) + ret := C.malloc(n) + // and this won't zero-initialize; do it ourselves + C.memset(ret, 0, n) + return ret } func freestr(str *C.char) {