From: Gerhard Sittig Date: Sat, 3 Nov 2018 13:28:56 +0000 (+0100) Subject: fluke-45: avoid NULL dereference in the probe routine X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=712f7d5e4093870fff650fb296d2425cb405a4c2;p=libsigrok.git fluke-45: avoid NULL dereference in the probe routine The Fluke 45 probe routine tries to detect whether the serial port is "in echo mode" (which already is questionable before the IDN query). In the absence of a response, the library segfaults. Fix it. --- diff --git a/src/hardware/fluke-45/api.c b/src/hardware/fluke-45/api.c index e15adaad..164cd5f9 100644 --- a/src/hardware/fluke-45/api.c +++ b/src/hardware/fluke-45/api.c @@ -68,8 +68,9 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) sdi->conn = scpi; /* Test for serial port ECHO enabled. */ + response = NULL; sr_scpi_get_string(scpi, "ECHO-TEST", &response); - if (strcmp(response, "ECHO-TEST") == 0) { + if (response && strcmp(response, "ECHO-TEST") == 0) { sr_err("Serial port ECHO is ON. Please turn it OFF!"); return NULL; }