diff options
| author | Simon Tatham <anakin@pobox.com> | 2017-12-27 09:34:53 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2017-12-27 09:34:53 +0000 |
| commit | 4b457fd6fb8121c75e7d748648d2599ee902f848 (patch) | |
| tree | 881ea6f3e69057bb15569605758ca26b634fca77 | |
| parent | 12107a73eff6b6f6a861ba156e94e13d9bcdbe56 (diff) | |
| download | halibut-4b457fd6fb8121c75e7d748648d2599ee902f848.zip halibut-4b457fd6fb8121c75e7d748648d2599ee902f848.tar.gz halibut-4b457fd6fb8121c75e7d748648d2599ee902f848.tar.bz2 halibut-4b457fd6fb8121c75e7d748648d2599ee902f848.tar.xz | |
Fix a segfault on bad input files.
I ran into this as a knock-on effect from having misspelled a section
name identifier (i.e. I had a \k{nonexistent-name} in my document).
Before I fix the document, I should fix the segfault!
| -rw-r--r-- | bk_html.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -2946,11 +2946,20 @@ static void html_href(htmloutput *ho, htmlfile *thisfile, rdaddc(&rs, '#'); rdaddsc(&rs, targetfrag); } + + /* If _neither_ of those conditions were true, we don't have a URL + * at all and will segfault when we pass url==NULL to element_attr. + * + * I think this can only occur as a knock-on effect from an input + * file error, but we still shouldn't crash, of course. */ + url = rs.text; element_open(ho, "a"); - element_attr(ho, "href", url); - sfree(url); + if (url) { + element_attr(ho, "href", url); + sfree(url); + } } static void html_fragment(htmloutput *ho, char const *fragment) |