1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

mailcap bug 1113: Don't leak values of duplicate fields

If a mailcap entry has two test commands or two descriptions,
free the first one before replacing it with the second one.
This commit is contained in:
Kalle Olavi Niemitalo 2011-04-17 20:06:24 +03:00 committed by Kalle Olavi Niemitalo
parent 450f227ea1
commit 534bb38c8a
2 changed files with 8 additions and 2 deletions

1
NEWS
View File

@ -16,6 +16,7 @@ To be released as 0.12pre6 or 0.12rc1.
header over that specified via the HTML meta tag. header over that specified via the HTML meta tag.
* bug 1084: Allow option names containing '+' and '*' in the option * bug 1084: Allow option names containing '+' and '*' in the option
manager. manager.
* minor bug 1113: Fix a small memory leak if a mailcap file is malformed.
Bugs that should be removed from NEWS before the 0.12.0 release: Bugs that should be removed from NEWS before the 0.12.0 release:

View File

@ -289,7 +289,11 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line)
entry->copiousoutput = 1; entry->copiousoutput = 1;
} else if (!c_strncasecmp(field, "test", 4)) { } else if (!c_strncasecmp(field, "test", 4)) {
entry->testcommand = get_mailcap_field_text(field + 4); /* Don't leak memory if a corrupted mailcap
* file has multiple test commands in the same
* line. */
mem_free_set(&entry->testcommand,
get_mailcap_field_text(field + 4));
if (!entry->testcommand) if (!entry->testcommand)
return 0; return 0;
@ -301,7 +305,8 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line)
} }
} else if (!c_strncasecmp(field, "description", 11)) { } else if (!c_strncasecmp(field, "description", 11)) {
entry->description = get_mailcap_field_text(field + 11); mem_free_set(&entry->description,
get_mailcap_field_text(field + 11));
if (!entry->description) if (!entry->description)
return 0; return 0;
} }