json/flat: don't try to parse empty files

avoids debug assertions fetching data pointer on empty mappings
This commit is contained in:
Danny Robson 2016-04-27 17:07:20 +10:00
parent 25913ac885
commit 5b58e0afa6

View File

@ -172,6 +172,9 @@ std::vector<json::flat::item>
json::flat::parse (const boost::filesystem::path &path)
{
util::mapped_file f (path.string ().c_str ());
if (f.empty ())
throw parse_error ("empty file");
return parse ((const char *)f.cbegin (), (const char*)f.cend ());
}