[CodeClean] check invalid param
authorJaeyun Jung <jy1210.jung@samsung.com>
Thu, 2 Jan 2025 01:23:15 +0000 (10:23 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 2 Jan 2025 03:34:44 +0000 (12:34 +0900)
Code clean, check invalid param case in custom connection.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c

index de4c3707cb25a740d099efc57c8324f3e359dcd2..08352d4d8289b1854ed86d4eca8b594722685cab 100644 (file)
@@ -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) {