summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bk_html.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bk_html.c b/bk_html.c
index f6b7f4b..294ac7a 100644
--- a/bk_html.c
+++ b/bk_html.c
@@ -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)