added checks for malloc failure
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 2 May 2001 15:16:03 +0000 (15:16 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 2 May 2001 15:16:03 +0000 (15:16 +0000)
comedi_calibrate/comedi_calibrate.c

index beb3910c5ac06b2283b643b10022bdb27e2265dd..b388d25d8293fc80c895d12d79f3c30385e322ef 100644 (file)
@@ -782,6 +782,11 @@ double check_gain_chan_x(linear_fit_t *l,int ad_chan,int range,int cdac)
        l->n=0;
 
        l->y_data=malloc(n*sizeof(double)/step);
+       if(l->y_data == NULL)
+       {
+               perror("comedi_calibrate");
+               exit(1);
+       }
 
        orig=caldacs[cdac].current;
 
@@ -923,6 +928,11 @@ int new_sv_measure(new_sv_t *sv)
        n=1<<sv->order;
 
        data=malloc(sizeof(sampl_t)*n);
+       if(data == NULL)
+       {
+               perror("comedi_calibrate");
+               exit(1);
+       }
 
        for(i=0;i<n;){
                sv->t.data=data+i;
@@ -961,6 +971,11 @@ int new_sv_measure_order(new_sv_t *sv,int order)
        n=1<<order;
 
        data=malloc(sizeof(sampl_t)*n);
+       if(data == NULL)
+       {
+               perror("comedi_calibrate");
+               exit(1);
+       }
 
        for(i=0;i<n;){
                sv->t.data=data+i;