Add NULL check for preventing crash 80/291780/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 21 Apr 2023 05:20:06 +0000 (14:20 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 21 Apr 2023 05:20:06 +0000 (14:20 +0900)
Change-Id: I45fcb2cbcbccfc2c7e15ed6678a1dffcc0c8d94b
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
service/src/nltk.c

index ae5d97a..a423678 100644 (file)
@@ -125,6 +125,7 @@ PyObject* nltk_get_module(const char* name)
 unsigned int nltk_get_size_from_list(PyObject* list)
 {
     int result = 0;
+    PRET_VM(!list, 0, "Input parameter [list] is NULL!");
 
     if (PyList_Check(list))
     {
@@ -143,6 +144,7 @@ unsigned int nltk_get_size_from_list(PyObject* list)
 unsigned int nltk_get_size_from_tuple(PyObject* tuple)
 {
     int result = 0;
+    PRET_VM(!tuple, 0, "Input parameter [tuple] is NULL!");
 
     if (PyTuple_Check(tuple))
     {
@@ -161,6 +163,7 @@ unsigned int nltk_get_size_from_tuple(PyObject* tuple)
 PyObject* nltk_get_element_from_list_by_index(PyObject* list, int index)
 {
     PyObject* element;
+    PRET_VM(!list, NULL, "Input parameter [list] is NULL!");
     if (PyList_Check(list))
     {
         if (index > (PyList_Size(list)-1) || (index < 0 ))