[Fix] Segfault when popping a task without a next task.
This commit is contained in:
parent
aafeaa43cd
commit
aade673567
9
src/ai.c
9
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user