From 5a26f06f8a5f7f5573332dcd772b025a8dbf69ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 2 Mar 2020 14:49:13 +0100 Subject: [PATCH] fix sf0x: check if device port is given otherwise we risk dereferencing a null pointer --- src/drivers/distance_sensor/sf0x/sf0x_main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/drivers/distance_sensor/sf0x/sf0x_main.cpp b/src/drivers/distance_sensor/sf0x/sf0x_main.cpp index 0284037d50..0ab7ef9136 100644 --- a/src/drivers/distance_sensor/sf0x/sf0x_main.cpp +++ b/src/drivers/distance_sensor/sf0x/sf0x_main.cpp @@ -48,6 +48,11 @@ static int start(const char *port, uint8_t rotation) return -1; } + if (port == nullptr) { + PX4_ERR("no device specified"); + return -1; + } + /* create the driver */ g_dev = new SF0X(port, rotation);