[svn-commits] mnicholson: testsuite/asterisk/trunk r643 - /asterisk/trunk/asttest/lib/lua/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 29 12:11:02 CDT 2010


Author: mnicholson
Date: Thu Jul 29 12:10:59 2010
New Revision: 643

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=643
Log:
Revert the previous change and just pop the name (and testsuite struct) instead.  Popping the test name string before using it could cause a crash.

Modified:
    asterisk/trunk/asttest/lib/lua/testlib.c

Modified: asterisk/trunk/asttest/lib/lua/testlib.c
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/testlib.c?view=diff&rev=643&r1=642&r2=643
==============================================================================
--- asterisk/trunk/asttest/lib/lua/testlib.c (original)
+++ asterisk/trunk/asttest/lib/lua/testlib.c Thu Jul 29 12:10:59 2010
@@ -52,12 +52,9 @@
  * \brief Push the current test's name on the stack and return a pointer to it.
  * \param L the lua state to use
  */
-static const char *get_test_name(lua_State *L) {
-	const char *c;
+static const char *push_test_name(lua_State *L) {
 	lua_getfield(L, LUA_REGISTRYINDEX, "testlib_name");
-	c = lua_tostring(L, -1);
-	lua_pop(L, 1);
-	return c;
+	return lua_tostring(L, -1);
 }
 
 /*
@@ -67,9 +64,11 @@
 static int lua_ts_log(lua_State *L) {
 	const char *string = luaL_checkstring(L, 1);
 	struct testsuite *ts = push_ts(L);
-	const char *name = get_test_name(L);
+	const char *name = push_test_name(L);
 
 	ts_log(ts, name, "%s", string);
+
+	lua_pop(L, 2); /* pop the test name and ts */
 
 	return 0;
 }




More information about the svn-commits mailing list