fix possible segfault
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 18 Jun 2003 00:06:20 +0000 (00:06 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 18 Jun 2003 00:06:20 +0000 (00:06 +0000)
comedi_calibrate/comedi_calibrate.c

index 117dc44b64f6fd1f7f1e43a59104c131213acedf..7cea71fb14a0b424ee3a0a3340e7a7b413f57a34 100644 (file)
@@ -1591,13 +1591,16 @@ double fractional_offset( calibration_setup_t *setup, int subdevice,
        unsigned int channel, unsigned int range, int obs )
 {
        comedi_range *range_ptr;
-       double target = setup->observables[obs].target;
+       double target;
        double reading;
-       unsigned int chanspec = setup->observables[obs].observe_insn.chanspec;
+       unsigned int chanspec;
        new_sv_t sv;
 
        if( subdevice < 0 || obs < 0 ) return 0.0;
 
+       chanspec = setup->observables[obs].observe_insn.chanspec;
+       target = setup->observables[obs].target;
+
        range_ptr = comedi_get_range( setup->dev, subdevice, channel, range );
        assert( range_ptr != NULL );