diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-10-05 12:49:01 +0200 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2020-10-19 15:35:43 +0200 |
commit | 577416d1a946382ab9f0c523e5fae755f9d71f69 (patch) | |
tree | 178b99a4d3d40137c0fcb765d655339f53b37728 /Meter.c | |
parent | 0db398d4c3472071b2814505242450cd8f831501 (diff) |
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().
Diffstat (limited to 'Meter.c')
-rw-r--r-- | Meter.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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)) |