Просмотр исходного кода

app_python3: use safer function PyBytes_AsString() instead of macro

- check if f_code filed in frame is set before using in log message
- GH #2335
Daniel-Constantin Mierla 5 лет назад
Родитель
Сommit
e680dd6ed6
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      src/modules/app_python3/apy_kemi.c

+ 3 - 3
src/modules/app_python3/apy_kemi.c

@@ -1822,9 +1822,9 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
 					" took too long [%u ms] (file:%s func:%s line:%d)\n",
 					(ket->mname.len>0)?ket->mname.s:"",
 					(ket->mname.len>0)?".":"", ket->fname.s, tdiff,
-					(pframe)?PyBytes_AS_STRING(pframe->f_code->co_filename):"",
-					(pframe)?PyBytes_AS_STRING(pframe->f_code->co_name):"",
-					(pframe)?PyCode_Addr2Line(pframe->f_code, pframe->f_lasti):0);
+					(pframe && pframe->f_code)?PyBytes_AsString(pframe->f_code->co_filename):"",
+					(pframe && pframe->f_code)?PyBytes_AsString(pframe->f_code->co_name):"",
+					(pframe && pframe->f_code)?PyCode_Addr2Line(pframe->f_code, pframe->f_lasti):0);
 		}
 	}