diff --git a/src/command.c b/src/command.c index 753f54c..80ebf25 100644 --- a/src/command.c +++ b/src/command.c @@ -124,6 +124,9 @@ command_t * get_command_line() command = (command_t *) malloc(sizeof(command_t)); line = interface_input_command(); + if (line == NULL) { + return 0; + } if (!strcmp(line, "quit") || !strcmp(line, "q")) { command -> type = COMMAND_QUIT; diff --git a/src/interface.c b/src/interface.c index 2c8bb42..e567a40 100644 --- a/src/interface.c +++ b/src/interface.c @@ -289,10 +289,16 @@ char * interface_input_command() case KEY_BACKSPACE: case KEY_DC: case 127: - if (i) { - mvwprintw(command_window, 0, i, " "); - line[--i] = '\0'; + if (!i) { /* exit out of command-line command */ + free(line); + curs_set(0); + noecho(); + wclear(command_window); + wrefresh(command_window); + return NULL; } + + line[--i] = '\0'; mvwprintw(command_window, 0, i + 1, " "); break;