Check return code from msgset_parse to prevent segmentation fault.
Showing
2 changed files
with
26 additions
and
10 deletions
... | @@ -49,11 +49,19 @@ mail_next (int argc, char **argv) | ... | @@ -49,11 +49,19 @@ mail_next (int argc, char **argv) |
49 | else | 49 | else |
50 | { | 50 | { |
51 | msgset_t *list = NULL; | 51 | msgset_t *list = NULL; |
52 | msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list); | 52 | int rc = msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list); |
53 | n = list->msg_part[0]; | 53 | if (!rc) |
54 | msgset_free (list); | 54 | { |
55 | if (util_get_message (mbox, n, &msg)) | 55 | n = list->msg_part[0]; |
56 | return 1; | 56 | msgset_free (list); |
57 | if (util_get_message (mbox, n, &msg)) | ||
58 | return 1; | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | util_error (_("No applicable message")); | ||
63 | return 1; | ||
64 | } | ||
57 | } | 65 | } |
58 | cursor = n; | 66 | cursor = n; |
59 | util_do_command("print"); | 67 | util_do_command("print"); | ... | ... |
... | @@ -49,11 +49,19 @@ mail_previous (int argc, char **argv) | ... | @@ -49,11 +49,19 @@ mail_previous (int argc, char **argv) |
49 | else | 49 | else |
50 | { | 50 | { |
51 | msgset_t *list = NULL; | 51 | msgset_t *list = NULL; |
52 | msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list); | 52 | int rc = msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list); |
53 | n = list->msg_part[0]; | 53 | if (!rc) |
54 | msgset_free (list); | 54 | { |
55 | if (util_get_message (mbox, n, &msg)) | 55 | n = list->msg_part[0]; |
56 | return 1; | 56 | msgset_free (list); |
57 | if (util_get_message (mbox, n, &msg)) | ||
58 | return 1; | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | util_error (_("No applicable message")); | ||
63 | return 1; | ||
64 | } | ||
57 | } | 65 | } |
58 | cursor = n; | 66 | cursor = n; |
59 | util_do_command ("print"); | 67 | util_do_command ("print"); | ... | ... |
-
Please register or sign in to post a comment