Browse code

app_lua: solve crash when setting a variable not convertible to string.

Vicente Hernando authored on 10/06/2013 10:14:54
Showing 1 changed files
... ...
@@ -990,6 +990,14 @@ static int lua_sr_pv_sets (lua_State *L)
990 990
 		LM_ERR("to few parameters [%d]\n",lua_gettop(L));
991 991
 		return 0;
992 992
 	}
993
+
994
+	if(!lua_isstring(L, -1))
995
+	{
996
+		LM_ERR("Cannot convert to a string when assigning value to variable: %s\n",
997
+			   lua_tostring(L, -2));
998
+		return 0;
999
+	}
1000
+
993 1001
 	memset(&val, 0, sizeof(pv_value_t));
994 1002
 	val.rs.s = (char*)lua_tostring(L, -1);
995 1003
 	val.rs.len = strlen(val.rs.s);