]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Initialize HPCS_MeasuredData properly after allocation
authorMichal Malý <madcatxster@gmail.com>
Thu, 10 Jul 2014 22:33:16 +0000 (00:33 +0200)
committerMichal Malý <madcatxster@gmail.com>
Thu, 10 Jul 2014 22:33:16 +0000 (00:33 +0200)
libhpcs.c

index a43f183000504f70882bd2f17cb034bb021be34b..09947ccb1fd9144c12151ec2ad6da1c434ab88d7 100644 (file)
--- 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)