From aade673567d35b1bbcd12b8bbfb5616480123370 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 15 Aug 2013 13:36:25 +0100 Subject: [PATCH] [Fix] Segfault when popping a task without a next task. --- src/ai.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ai.c b/src/ai.c index 6d882ce..aae8f2f 100644 --- a/src/ai.c +++ b/src/ai.c @@ -457,8 +457,13 @@ static int ai_pushtask(lua_State* L) { static int ai_poptask(lua_State* L) { (void)L; /* Just a hack to avoid -W -Wall warnings. */ Task* t = cur_pilot->task; - cur_pilot->task = t->next; - t->next = NULL; + if(t != NULL) { + cur_pilot->task = t->next; + t->next = NULL; + } else { + LLUA_DEBUG("Trying to pop task when there are no tasks in stack"); + return 0; + } ai_freetask(t); return 0; }