From 3005297af2e1b4a8355e3f27e43541f6a70aa314 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 7 Jun 2010 13:20:38 +0200 Subject: [PATCH] Check for being properly setup before activating a thread. Fixes a potential although unlikely null-dereference. --- src/tm-threads.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index 50d13bffc7..a712216dd6 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -523,6 +523,14 @@ void *TmThreadsSlotVar(void *td) { if (tv->thread_setup_flags != 0) TmThreadSetupOptions(tv); + /* check if we are setup properly */ + if (s == NULL || s->s == NULL || tv->tmqh_in == NULL || tv->tmqh_out == NULL) { + EngineKill(); + + TmThreadsSetFlag(tv, THV_CLOSED); + pthread_exit((void *) -1); + } + for (slot = s->s; slot != NULL; slot = slot->slot_next) { if (slot->SlotThreadInit != NULL) { r = slot->SlotThreadInit(tv, slot->slot_initdata, &slot->slot_data); @@ -545,10 +553,8 @@ void *TmThreadsSlotVar(void *td) { /* input a packet */ p = tv->tmqh_in(tv); - if (p == NULL) { - //printf("%s: TmThreadsSlotVar: p == NULL\n", tv->name); - } else { - + if (p != NULL) { + /* run the thread module(s) */ r = TmThreadsSlotVarRun(tv, p, s->s); if (r == TM_ECODE_FAILED) { TmqhOutputPacketpool(tv, p);