From 6f7e527e92d3c259b51afa278ee7fc7ced5e8589 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 20 Sep 2012 22:09:30 +0200 Subject: [PATCH] luajit: fix crash at shutdown / rule reload if lua script didn't properly init. --- src/detect-engine.c | 4 +++- src/detect-luajit.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/detect-engine.c b/src/detect-engine.c index 8adf3f964f..1db62a5b43 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -724,7 +724,9 @@ static void DetectEngineThreadCtxDeinitKeywords(DetectEngineCtx *de_ctx, DetectE if (de_ctx->keyword_id > 0) { DetectEngineThreadKeywordCtxItem *item = de_ctx->keyword_list; while (item) { - item->FreeFunc(det_ctx->keyword_ctxs_array[item->id]); + if (det_ctx->keyword_ctxs_array[item->id] != NULL) + item->FreeFunc(det_ctx->keyword_ctxs_array[item->id]); + item = item->next; } det_ctx->keyword_ctxs_size = 0; diff --git a/src/detect-luajit.c b/src/detect-luajit.c index 3584996b47..8d405c628a 100644 --- a/src/detect-luajit.c +++ b/src/detect-luajit.c @@ -383,6 +383,7 @@ static void *DetectLuajitThreadInit(void *data) { t->flags = luajit->flags; t->luastate = luaL_newstate(); + if (t->luastate == NULL) { SCLogError(SC_ERR_LUAJIT_ERROR, "couldn't set up luastate"); goto error; @@ -412,11 +413,11 @@ error: } static void DetectLuajitThreadFree(void *ctx) { - DetectLuajitThreadData *t = (DetectLuajitThreadData *)ctx; - - lua_close(t->luastate); - - SCFree(t); + if (ctx != NULL) { + DetectLuajitThreadData *t = (DetectLuajitThreadData *)ctx; + lua_close(t->luastate); + SCFree(t); + } } /**