From 577416d1a946382ab9f0c523e5fae755f9d71f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 5 Oct 2020 12:49:01 +0200 Subject: Assert allocating non-zero size memory Allocating zero size memory results in implementation-defined behavior: man:malloc(3) : If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). --- Meter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Meter.c') diff --git a/Meter.c b/Meter.c index 84370362..fa1eacb4 100644 --- a/Meter.c +++ b/Meter.c @@ -38,7 +38,7 @@ Meter* Meter_new(struct ProcessList_* pl, int param, const MeterClass* type) { this->param = param; this->pl = pl; this->curItems = type->maxItems; - this->values = xCalloc(type->maxItems, sizeof(double)); + this->values = type->maxItems ? xCalloc(type->maxItems, sizeof(double)) : NULL; this->total = type->total; this->caption = xStrdup(type->caption); if (Meter_initFn(this)) -- cgit v1.2.3