[Fix] Segfault when popping a task without a next task.

This commit is contained in:
Allanis 2013-08-15 13:36:25 +01:00
parent aafeaa43cd
commit aade673567

View File

@ -457,8 +457,13 @@ static int ai_pushtask(lua_State* L) {
static int ai_poptask(lua_State* L) { static int ai_poptask(lua_State* L) {
(void)L; /* Just a hack to avoid -W -Wall warnings. */ (void)L; /* Just a hack to avoid -W -Wall warnings. */
Task* t = cur_pilot->task; Task* t = cur_pilot->task;
if(t != NULL) {
cur_pilot->task = t->next; cur_pilot->task = t->next;
t->next = NULL; t->next = NULL;
} else {
LLUA_DEBUG("Trying to pop task when there are no tasks in stack");
return 0;
}
ai_freetask(t); ai_freetask(t);
return 0; return 0;
} }