From c75476cc69fdc8c6a1d3afd4bdf7ac6c087da6df Mon Sep 17 00:00:00 2001 From: Jaeyun Jung Date: Thu, 2 Jan 2025 10:23:15 +0900 Subject: [PATCH] [CodeClean] check invalid param Code clean, check invalid param case in custom connection. Signed-off-by: Jaeyun Jung --- .../nnstreamer-edge-custom-impl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c b/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c index de4c370..08352d4 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c +++ b/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c @@ -14,6 +14,7 @@ #include "nnstreamer-edge-custom-impl.h" #include "nnstreamer-edge-log.h" +#include "nnstreamer-edge-util.h" typedef const nns_edge_custom_s *custom_get_instance (void); @@ -69,6 +70,12 @@ nns_edge_custom_load (custom_connection_s * custom, const char *lib_path) nns_edge_custom_s *custom_h; int ret; + if (!STR_IS_VALID (lib_path)) + return NNS_EDGE_ERROR_INVALID_PARAMETER; + + if (!custom) + return NNS_EDGE_ERROR_INVALID_PARAMETER; + ret = _load_custom_library (custom, lib_path); if (NNS_EDGE_ERROR_NONE != ret) { nns_edge_loge @@ -238,6 +245,10 @@ nns_edge_custom_send_data (custom_connection_s * custom, nns_edge_data_h data_h) if (!custom || !custom->instance) return NNS_EDGE_ERROR_INVALID_PARAMETER; + ret = nns_edge_data_is_valid (data_h); + if (NNS_EDGE_ERROR_NONE != ret) + return ret; + custom_h = custom->instance; ret = custom_h->nns_edge_custom_send_data (custom->priv, data_h); @@ -261,6 +272,9 @@ nns_edge_custom_set_info (custom_connection_s * custom, const char *key, if (!custom || !custom->instance) return NNS_EDGE_ERROR_INVALID_PARAMETER; + if (!STR_IS_VALID (key) || !STR_IS_VALID (value)) + return NNS_EDGE_ERROR_INVALID_PARAMETER; + custom_h = custom->instance; if (custom_h->nns_edge_custom_set_info) { @@ -286,6 +300,9 @@ nns_edge_custom_get_info (custom_connection_s * custom, const char *key, if (!custom || !custom->instance) return NNS_EDGE_ERROR_INVALID_PARAMETER; + if (!STR_IS_VALID (key) || !value) + return NNS_EDGE_ERROR_INVALID_PARAMETER; + custom_h = custom->instance; if (custom_h->nns_edge_custom_get_info) {