From eaca77c2def6d5427f0ba6561966032586be909d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 8 Jan 2015 12:44:36 +0100 Subject: [PATCH] Crash fix - throw if file can't be opened --- src/asciimapsource.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/asciimapsource.cpp b/src/asciimapsource.cpp index ce009b0..438819e 100644 --- a/src/asciimapsource.cpp +++ b/src/asciimapsource.cpp @@ -102,6 +102,11 @@ namespace dkh { throw std::runtime_error("Invalid data: can't parse file"); } + if (grammar.lengths.empty()) { + m_mapSize.x() = m_mapSize.y() = 0; + throw std::runtime_error("Invalid data: can't guess map size"); + } + //Only look at the front. Besides a bug in spirit makes the other counts //invalid, see //http://boost.2283326.n4.nabble.com/Possible-bug-in-line-pos-iterator-td4636592.html