Bugfix
* libmailutils/base/ctparse.c (parse_type) (parse_subtype): Fix memory allocation
Showing
2 changed files
with
3 additions
and
3 deletions
gint @ fd86bf7d
... | @@ -60,7 +60,7 @@ parse_type (const char *input, mu_content_type_t ct) | ... | @@ -60,7 +60,7 @@ parse_type (const char *input, mu_content_type_t ct) |
60 | || !(mu_isalnum (input[i]) || input[i] == '-' || input[i] == '_')) | 60 | || !(mu_isalnum (input[i]) || input[i] == '-' || input[i] == '_')) |
61 | return MU_ERR_PARSE; | 61 | return MU_ERR_PARSE; |
62 | } | 62 | } |
63 | ct->type = malloc (i); | 63 | ct->type = malloc (i + 1); |
64 | if (!ct->type) | 64 | if (!ct->type) |
65 | return ENOMEM; | 65 | return ENOMEM; |
66 | memcpy (ct->type, input, i); | 66 | memcpy (ct->type, input, i); |
... | @@ -83,7 +83,7 @@ parse_subtype (const char *input, mu_content_type_t ct) | ... | @@ -83,7 +83,7 @@ parse_subtype (const char *input, mu_content_type_t ct) |
83 | if (!ISTOKEN (input[i])) | 83 | if (!ISTOKEN (input[i])) |
84 | return MU_ERR_PARSE; | 84 | return MU_ERR_PARSE; |
85 | } | 85 | } |
86 | ct->subtype = malloc (i); | 86 | ct->subtype = malloc (i + 1); |
87 | if (!ct->subtype) | 87 | if (!ct->subtype) |
88 | return ENOMEM; | 88 | return ENOMEM; |
89 | memcpy (ct->subtype, input, i); | 89 | memcpy (ct->subtype, input, i); | ... | ... |
-
Please register or sign in to post a comment