Be careful about unparsable bibtex years

Handle gracefully the case where the regex that parses a year fails.

This is a fixup to ba171930 (spotted by coverity).
This commit is contained in:
Jean-Marc Lasgouttes 2017-03-10 10:32:38 +01:00
parent 4b8e5a9d53
commit e2f2915f8e

View File

@ -417,7 +417,9 @@ docstring const BibTeXInfo::getYear() const
static regex const ereg(".*/[-]?([\\d]{4}).*");
smatch sm;
string const date = to_utf8(year);
regex_match(date, sm, yreg);
if (!regex_match(date, sm, yreg))
// cannot parse year.
return docstring();
year = from_ascii(sm[1]);
// check for an endyear
if (regex_match(date, sm, ereg))