Module Name: src
Committed By: christos
Date: Thu Jan 28 03:32:29 UTC 2016
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
Don't crash if we have a missing section.
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/makemandb/makemandb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.30 src/usr.sbin/makemandb/makemandb.c:1.31
--- src/usr.sbin/makemandb/makemandb.c:1.30 Fri Dec 18 09:30:16 2015
+++ src/usr.sbin/makemandb/makemandb.c Wed Jan 27 22:32:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.30 2015/12/18 14:30:16 christos Exp $ */
+/* $NetBSD: makemandb.c,v 1.31 2016/01/28 03:32:29 christos Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* Copyright (c) 2011 Kristaps Dzonsons <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.30 2015/12/18 14:30:16 christos Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.31 2016/01/28 03:32:29 christos Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -945,11 +945,21 @@ set_section(const struct mdoc *md, const
{
if (md) {
const struct mdoc_meta *md_meta = mdoc_meta(md);
- rec->section[0] = md_meta->msec[0];
+ if (md_meta->msec == NULL) {
+ rec->section[0] = '?';
+ } else
+ rec->section[0] = md_meta->msec[0];
} else if (m) {
const struct man_meta *m_meta = man_meta(m);
- rec->section[0] = m_meta->msec[0];
- }
+ if (m_meta->msec == NULL)
+ rec->section[0] = '?';
+ else
+ rec->section[0] = m_meta->msec[0];
+ } else
+ return;
+
+ if (rec->section[0] == '?' && mflags.verbosity == 2)
+ warnx("%s: Missing section number", rec->file_path);
}
/*