From 08020429fea30eac0b2e8078f95f48e59c242cc1 Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Mon, 13 May 2024 15:49:28 +0900 Subject: [PATCH] Add try-catch for sensord_disconnect function The capi function 'sensor_destroy_listener' can throw std::invalid_argument but this function can be used in C(which cannot handle thrown exceptions) so a try-catch statement is added to handle this exception. This patch will solve the SVACE report with WGID 203810. Change-Id: I5eda70a6afb62f63c823df6f96c73271872def4d Signed-off-by: SangYoun Kwak --- src/sensor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sensor.cpp b/src/sensor.cpp index 9473be7..0225b18 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -446,7 +446,13 @@ int sensor_destroy_listener(sensor_listener_h listener) if (listener->magic != SENSOR_LISTENER_MAGIC) return SENSOR_ERROR_INVALID_PARAMETER; - sensord_disconnect(listener->id); + try { + sensord_disconnect(listener->id); + } catch (std::invalid_argument &e) { + _E("sensord_disconnect failed: %s", e.what()); + return SENSOR_ERROR_INVALID_PARAMETER; + } + listener->magic = 0; delete (sensor_listener_s *)listener; -- 2.7.4