From df5210907d35c9c05ff1f9bbd34c095edfc34a82 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 21 Apr 2023 14:20:06 +0900 Subject: [PATCH] Add NULL check for preventing crash Change-Id: I45fcb2cbcbccfc2c7e15ed6678a1dffcc0c8d94b Signed-off-by: Jihoon Kim --- service/src/nltk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/src/nltk.c b/service/src/nltk.c index ae5d97a..a423678 100644 --- a/service/src/nltk.c +++ b/service/src/nltk.c @@ -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 )) -- 2.7.4