diff --git a/NEWS b/NEWS index 296dd48e..3916c435 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,7 @@ Miscellaneous: terminal charset, and ELinks 0.12pre5 was the first release that supported UTF-8 as the dump charset.) * Really retry forever when connection.retries = 0. +* minor bug 1113: Fix a small memory leak if a mailcap file is malformed. * enhancement: Session-specific options. Any options changed with toggle-* actions no longer affect other tabs or other terminals. * Do not crash when document.browse.minimum_refresh_time = 0 and diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index 4c13c184..eb186e09 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -289,7 +289,11 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line) entry->copiousoutput = 1; } 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) return 0; @@ -301,7 +305,8 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line) } } 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) return 0; }