summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-01-16 12:11:56 +0000
committerColin Watson <cjwatson@debian.org>2018-01-16 12:13:23 +0000
commitb32977ff73220cd351387abe558fb523d1deedbb (patch)
tree7b215f7e89c138b1ae0a1fc649bda854cba585ef
parent5da2575882bf783704bd9c2fd3f42b75bfeb00b4 (diff)
downloadman-db-b32977ff73220cd351387abe558fb523d1deedbb.tar.gz
Fix a segfault in 'man -D --help'
Reported by Jiri Kucera. * src/man.c (init_html_pager): New function. (parse_opt): Call init_html_pager rather than setting html_pager to NULL. (help_filter): Assert that browser is non-NULL. (main): Call init_html_pager rather than doing the same thing directly. * NEWS: Document this.
-rw-r--r--NEWS2
-rw-r--r--src/man.c17
2 files changed, 13 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index ff1ff58..0e0775c 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ Major changes since man-db 2.7.6.1:
hyphenation, then take account of those when looking for a
preprocessor line at the start of the page.
+ * Fix a segfault in 'man -D --help'.
+
Improvements:
-------------
diff --git a/src/man.c b/src/man.c
index 6bc9642..6b3fa80 100644
--- a/src/man.c
+++ b/src/man.c
@@ -347,6 +347,13 @@ static struct argp_option options[] = {
{ 0 }
};
+static void init_html_pager (void)
+{
+ html_pager = getenv ("BROWSER");
+ if (!html_pager)
+ html_pager = WEB_BROWSER;
+}
+
static error_t parse_opt (int key, char *arg, struct argp_state *state)
{
static int apropos, whatis; /* retain values between calls */
@@ -371,7 +378,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
ditroff = 0;
gxditview = NULL;
htmlout = 0;
- html_pager = NULL;
+ init_html_pager ();
#endif
roff_device = want_encoding = extension = pager =
locale = alt_system_name = external =
@@ -584,6 +591,7 @@ static char *help_filter (int key, const char *text,
# ifdef TROFF_IS_GROFF
case 'H':
browser = html_pager;
+ assert (browser);
if (STRNEQ (browser, "exec ", 5))
browser += 5;
return xasprintf (text, browser);
@@ -4058,11 +4066,8 @@ int main (int argc, char *argv[])
#ifdef TROFF_IS_GROFF
/* used in --help, so initialise early */
- if (!html_pager) {
- html_pager = getenv ("BROWSER");
- if (!html_pager)
- html_pager = WEB_BROWSER;
- }
+ if (!html_pager)
+ init_html_pager ();
#endif /* TROFF_IS_GROFF */
/* First of all, find out if $MANOPT is set. If so, put it in