From 0936d89ac8b5fdf849242a3e5bf167c5b5d8b7e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Fri, 11 Jul 2014 00:33:16 +0200 Subject: [PATCH] Initialize HPCS_MeasuredData properly after allocation --- libhpcs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libhpcs.c b/libhpcs.c index a43f183..09947cc 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -6,7 +6,20 @@ struct HPCS_MeasuredData* hpcs_alloc() { - return malloc(sizeof(struct HPCS_MeasuredData)); + struct HPCS_MeasuredData* mdata = malloc(sizeof(struct HPCS_MeasuredData)); + if (mdata == NULL) + return NULL; + + mdata->file_description = NULL; + mdata->sample_info = NULL; + mdata->operator_name = NULL; + mdata->method_name = NULL; + mdata->cs_ver = NULL; + mdata->cs_rev = NULL; + mdata->y_units = NULL; + mdata->data = NULL; + + return mdata; } char* hpcs_error_to_string(const enum HPCS_RetCode err) -- 2.43.5