]> sigrok.org Git - libsigrok.git/commitdiff
rs9lcd: Fix segfault with unusual modes.
authorAlexandru Gagniuc <redacted>
Tue, 25 Dec 2012 22:21:24 +0000 (16:21 -0600)
committerUwe Hermann <redacted>
Tue, 25 Dec 2012 22:43:30 +0000 (23:43 +0100)
Some unusual modes required re-parsing the value. Instead of assigning the
re-parsed value to *floatval, it was reassigned directly to *analog->data;
however, analog->data is not initialized at this point, causing a segfault.
This situation was created when moving the radioshack-dmm code to serial-dmm,
with the segfault not being observed at that time.

Do not write directly to analog->data, but instead use the intermediate
variable rawval.

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/common/dmm/rs9lcd.c

index d184aca712736d434d661c60ecab508aca535a86..25e330705c1d6beee6a5793a9b15f76ff73b4a96 100644 (file)
@@ -369,7 +369,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
        case MODE_CONT:
                analog->mq = SR_MQ_CONTINUITY;
                analog->unit = SR_UNIT_BOOLEAN;
-               *analog->data = is_shortcirc(rs_packet);
+               rawval = is_shortcirc(rs_packet);
                break;
        case MODE_DIODE:
                analog->mq = SR_MQ_VOLTAGE;
@@ -394,7 +394,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
                } else {
                        /* We have either HI or LOW. */
                        analog->unit = SR_UNIT_BOOLEAN;
-                       *analog->data = is_logic_high(rs_packet);
+                       rawval = is_logic_high(rs_packet);
                }
                break;
        case MODE_HFE:
@@ -415,7 +415,7 @@ SR_PRIV int sr_rs9lcd_parse(const uint8_t *buf, float *floatval,
        case MODE_TEMP:
                analog->mq = SR_MQ_TEMPERATURE;
                /* We need to reparse. */
-               *analog->data = lcd_to_double(rs_packet, READ_TEMP);
+               rawval = lcd_to_double(rs_packet, READ_TEMP);
                analog->unit = is_celsius(rs_packet) ?
                                SR_UNIT_CELSIUS : SR_UNIT_FAHRENHEIT;
                break;