command.c: fix "alias" command crashing when no aliases were registered

if we dont have aliases list how do we check the next alias in the list aswell?
This commit is contained in:
Alug 2025-12-07 20:40:30 +01:00 committed by NepDisk
parent d5a4ef0e52
commit 0f4cf9ff8c

View file

@ -750,7 +750,7 @@ static void COM_Alias_f(void)
CONS_Printf(M_GetText("All aliases that start with \x87'%s'\x80 are:\n"), begin);
int count = 0;
for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
for (cmdalias_t *head = com_alias; head != NULL && head->next != NULL; head = head->next)
{
if (strncmp(begin, head->name, szBegin) == 0)
{
@ -771,7 +771,7 @@ static void COM_Alias_f(void)
/* Display alias subtext, show all aliases. */
CONS_Printf(M_GetText("alias <name> <command>: create a shortcut command that executes other command(s)\n"));
for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
for (cmdalias_t *head = com_alias; head != NULL && head->next != NULL; head = head->next)
{
CONS_Printf(alias_format, head->name, head->value);
}