solve some static check questions for shell/src/

This commit is contained in:
fang 2019-12-09 13:09:32 +08:00
parent 84d955e738
commit cf014abd96
2 changed files with 9 additions and 5 deletions

View File

@ -780,6 +780,7 @@ void source_file(TAOS *con, char *fptr) {
if (wordexp(fptr, &full_path, 0) != 0) {
fprintf(stderr, "ERROR: illegal file name\n");
free(cmd);
return;
}
@ -788,6 +789,7 @@ void source_file(TAOS *con, char *fptr) {
if (access(fname, R_OK) == -1) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path);
free(cmd);
return;
}
@ -795,6 +797,7 @@ void source_file(TAOS *con, char *fptr) {
if (f == NULL) {
fprintf(stderr, "ERROR: failed to open file %s\n", fname);
wordfree(&full_path);
free(cmd);
return;
}

View File

@ -277,7 +277,10 @@ void *shellLoopQuery(void *arg) {
pthread_cleanup_push(cleanup_handler, NULL);
char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL){
tscError("failed to malloc command");
return NULL;
}
while (1) {
// Read command from shell.
@ -286,10 +289,8 @@ void *shellLoopQuery(void *arg) {
shellReadCommand(con, command);
reset_terminal_mode();
if (command != NULL) {
// Run the command
shellRunCommand(con, command);
}
// Run the command
shellRunCommand(con, command);
}
pthread_cleanup_pop(1);