فهرست منبع

app_lua: do lua_checkstack() to ensure enough capacity on Lua stack

- Lua doesn't do automatic management of the stack
  * http://www.lua.org/manual/5.1/manual.html#3.2
- do exit on insufficient capacity
- based on the report by GH #1433
Daniel-Constantin Mierla 7 سال پیش
والد
کامیت
f6d69d87ab
1فایلهای تغییر یافته به همراه7 افزوده شده و 3 حذف شده
  1. 7 3
      src/modules/app_lua/app_lua_sr.c

+ 7 - 3
src/modules/app_lua/app_lua_sr.c

@@ -1970,10 +1970,14 @@ void lua_sr_kemi_register_libs(lua_State *L)
 				}
 				n++;
 			}
+			if(!lua_checkstack(L, i+8)) {
+				LM_ERR("not enough Lua stack capacity\n");
+				exit(-1);
+			}
 			luaL_openlib(L, mname, _sr_crt_KSRMethods, 0);
-			LM_DBG("initializing kemi sub-module: %s (%s)\n", mname,
-					emods[k].kexp[0].mname.s);
+			LM_DBG("initializing kemi sub-module: %s (%s) (%d/%d/%d)\n", mname,
+					emods[k].kexp[0].mname.s, i, k, n);
 		}
 	}
-	LM_DBG("module 'KSR' has been initialized\n");
+	LM_DBG("module 'KSR' has been initialized (%d/%d)\n", emods_size, n);
 }