[sr-dev] git:master: app_lua: solve crash when setting a variable not convertible to string.

Vicente Hernando vhernando at systemonenoc.com
Mon Jun 10 12:22:40 CEST 2013


Module: sip-router
Branch: master
Commit: 4af0bc13901525a5638c2c64b863f377e033903f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4af0bc13901525a5638c2c64b863f377e033903f

Author: Vicente Hernando <vhernando at systemonenoc.com>
Committer: Vicente Hernando <vhernando at systemonenoc.com>
Date:   Mon Jun 10 12:14:54 2013 +0200

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

---

 modules/app_lua/app_lua_sr.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c
index 4011e52..93b89b8 100644
--- a/modules/app_lua/app_lua_sr.c
+++ b/modules/app_lua/app_lua_sr.c
@@ -990,6 +990,14 @@ static int lua_sr_pv_sets (lua_State *L)
 		LM_ERR("to few parameters [%d]\n",lua_gettop(L));
 		return 0;
 	}
+
+	if(!lua_isstring(L, -1))
+	{
+		LM_ERR("Cannot convert to a string when assigning value to variable: %s\n",
+			   lua_tostring(L, -2));
+		return 0;
+	}
+
 	memset(&val, 0, sizeof(pv_value_t));
 	val.rs.s = (char*)lua_tostring(L, -1);
 	val.rs.len = strlen(val.rs.s);




More information about the sr-dev mailing list