aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-04-03 00:12:32 +0200
committerPeter Wu <peter@lekensteyn.nl>2016-04-10 21:51:14 +0000
commitc82cbfdc724a8a9896bd27225e33a0e5a8fc2e1e (patch)
tree7d9b820a13d7356e1fb57de02d25db446cc6738f /epan/wslua
parent4a37458c5d2ac918dabbb9d3fde029e3eb30fa04 (diff)
wslua: Abort on out of memory
The current wslua code does not properly handle out of memory conditions. Since recovering from OOM is difficult in many places, just abort the program (which is done by g_realloc). Change-Id: Idae68d08c90c82ba5df18a28cc1e507d61d20e78 Reviewed-on: https://code.wireshark.org/review/14786 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/wslua')
-rw-r--r--epan/wslua/init_wslua.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 0a3c4bf109..4a8ff1fb44 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -717,6 +717,14 @@ wslua_get_expert_field(const int group, const int severity)
return &ei_lua_error;
}
+static void *
+wslua_allocf(void *ud _U_, void *ptr, size_t osize _U_, size_t nsize)
+{
+ /* g_realloc frees ptr if nsize==0 and returns NULL (as desired).
+ * Furthermore it simplifies error handling by aborting on OOM */
+ return g_realloc(ptr, nsize);
+}
+
void wslua_init(register_cb cb, gpointer client_data) {
gchar* filename;
const funnel_ops_t* ops = funnel_get_funnel_ops();
@@ -831,7 +839,7 @@ void wslua_init(register_cb cb, gpointer client_data) {
}
if (!L) {
- L = luaL_newstate();
+ L = lua_newstate(wslua_allocf, NULL);
}
WSLUA_INIT(L);