There is indeed a bug here. These are the lines as they are in the current HEAD commit:
Code:
case AEDIT_ACTION_NAME:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->command)
free(OLC_ACTION(d)->command);
OLC_ACTION(d)->command = strdup(arg);
break;
case AEDIT_SORT_AS:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->sort_as) {
free(OLC_ACTION(d)->sort_as);
OLC_ACTION(d)->sort_as = strdup(arg);
}
break;
As it is, sort_as can never be set. The correct version should be:
Code:
case AEDIT_ACTION_NAME:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->command)
free(OLC_ACTION(d)->command);
OLC_ACTION(d)->command = strdup(arg);
break;
case AEDIT_SORT_AS:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->sort_as)
free(OLC_ACTION(d)->sort_as);
OLC_ACTION(d)->sort_as = strdup(arg);
break;
The point being, if sort_as is NULL, no strdup call will happen in the original version.
Note also, that I removed two spaces from the "OLC_ACTION(d)->command = strdup(arg);" line to silence the linter