Fix fatal error when using the help command

Check that an action is defined for the key.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2017-08-11 09:35:43 +02:00 committed by Lukas Fleischer
parent 0df373f26a
commit 53db74ab34

View File

@ -103,13 +103,14 @@ int display_help(const char *topic)
asprintf(&path, "%s/%s.txt", basedir, topic);
if (!io_file_exists(path) && keys_str2int(topic) > 0 &&
keys_get_action(keys_str2int(topic)) > 0) {
if (!io_file_exists(path)) {
int ch = keys_str2int(topic);
enum key action = keys_get_action(ch);
topic = keys_get_label(action);
mem_free(path);
asprintf(&path, "%s/%s.txt", basedir, topic);
if (ch > 0 && action > 0 && action != KEY_UNDEF) {
topic = keys_get_label(action);
mem_free(path);
asprintf(&path, "%s/%s.txt", basedir, topic);
}
}
if (!io_file_exists(path)) {