Kaynağa Gözat

modules/app_lua: Fix to lua_sr_pv_is_null()

- Previously this function returned an error when it could not retrieve the pv
  (for example if it did not exist).  As Lua is not a language in which you
  have to declare variables not existing is equivalent to NULL.  This function
  now treats a pv that does not exist as NULL.
pd 14 yıl önce
ebeveyn
işleme
4e4069330f
1 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 3 2
      modules/app_lua/app_lua_sr.c

+ 3 - 2
modules/app_lua/app_lua_sr.c

@@ -1081,8 +1081,9 @@ static int lua_sr_pv_is_null (lua_State *L)
 	memset(&val, 0, sizeof(pv_value_t));
 	memset(&val, 0, sizeof(pv_value_t));
 	if(pv_get_spec_value(env_L->msg, &pvs, &val) != 0)
 	if(pv_get_spec_value(env_L->msg, &pvs, &val) != 0)
 	{
 	{
-		LM_ERR("unable to get pv value for [%s]\n", pvn.s);
-		return 0;
+		LM_NOTICE("unable to get pv value for [%s]\n", pvn.s);
+		lua_pushboolean(L, 1);
+		return 1;
 	}
 	}
 	if(val.flags&PV_VAL_NULL)
 	if(val.flags&PV_VAL_NULL)
 	{
 	{