(util_do_command): Coredumped in false branches of `if ... endif' statement. Fixed.
Showing
1 changed file
with
12 additions
and
8 deletions
... | @@ -83,6 +83,7 @@ util_do_command (const char *c, ...) | ... | @@ -83,6 +83,7 @@ util_do_command (const char *c, ...) |
83 | char **argv = NULL; | 83 | char **argv = NULL; |
84 | int status = 0; | 84 | int status = 0; |
85 | function_t *command; | 85 | function_t *command; |
86 | int exec = 1; | ||
86 | char *cmd = NULL; | 87 | char *cmd = NULL; |
87 | va_list ap; | 88 | va_list ap; |
88 | static const char *delim = "="; | 89 | static const char *delim = "="; |
... | @@ -95,29 +96,29 @@ util_do_command (const char *c, ...) | ... | @@ -95,29 +96,29 @@ util_do_command (const char *c, ...) |
95 | 96 | ||
96 | if (cmd) | 97 | if (cmd) |
97 | { | 98 | { |
98 | struct mail_command_entry entry; | ||
99 | |||
100 | /* Ignore comments */ | 99 | /* Ignore comments */ |
101 | if (cmd[0] == '#') { | 100 | if (cmd[0] == '#') |
101 | { | ||
102 | free (cmd); | 102 | free (cmd); |
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* Hitting return i.e. no command, is equivalent to next | 106 | /* Hitting return i.e. no command, is equivalent to next |
107 | according to the POSIX spec. */ | 107 | according to the POSIX spec. */ |
108 | if (cmd[0] == '\0') { | 108 | if (cmd[0] == '\0') |
109 | { | ||
109 | free (cmd); | 110 | free (cmd); |
110 | cmd = strdup ("next"); | 111 | cmd = strdup ("next"); |
111 | } | 112 | } |
112 | 113 | ||
113 | if (argcv_get (cmd, delim, NULL, &argc, &argv) == 0) | 114 | if (argcv_get (cmd, delim, NULL, &argc, &argv) == 0) |
114 | { | 115 | { |
116 | struct mail_command_entry entry; | ||
115 | 117 | ||
116 | entry = util_find_entry (mail_command_table, argv[0]); | 118 | entry = util_find_entry (mail_command_table, argv[0]); |
117 | |||
118 | /* Make sure we are not in any if/else */ | ||
119 | if (! (if_cond () == 0 && (entry.flags & EF_FLOW) == 0)) | ||
120 | command = entry.func; | 119 | command = entry.func; |
120 | /* Make sure we are not in any if/else */ | ||
121 | exec = !(if_cond () == 0 && (entry.flags & EF_FLOW) == 0); | ||
121 | } | 122 | } |
122 | free (cmd); | 123 | free (cmd); |
123 | } | 124 | } |
... | @@ -125,10 +126,13 @@ util_do_command (const char *c, ...) | ... | @@ -125,10 +126,13 @@ util_do_command (const char *c, ...) |
125 | command = util_command_get ("quit"); | 126 | command = util_command_get ("quit"); |
126 | 127 | ||
127 | if (command != NULL) | 128 | if (command != NULL) |
129 | { | ||
130 | if (exec) | ||
128 | status = command (argc, argv); | 131 | status = command (argc, argv); |
132 | } | ||
129 | else | 133 | else |
130 | { | 134 | { |
131 | util_error("Unknown command: %s", argv[0]); | 135 | util_error ("Unknown command: %s", argv[0]); |
132 | status = 1; | 136 | status = 1; |
133 | } | 137 | } |
134 | 138 | ... | ... |
-
Please register or sign in to post a comment