Commit 0f705faa 0f705faa6c5079c03319a49f37912f7f49bce6e1 by Sergey Poznyakoff

Bugfix

* libmailutils/base/ctparse.c (parse_type)
(parse_subtype): Fix memory allocation
1 parent 506086e0
gint @ fd86bf7d
1 Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a 1 Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
......
...@@ -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);
......