From 991cb4d02abb0f0fb16ce45ded93a84ebd6572ba Mon Sep 17 00:00:00 2001 From: suhrke Date: Mon, 3 Jul 2017 19:27:18 -0700 Subject: [PATCH] EntityConverter::convertTarget made safer --- ReflexToQ3/includes/EntityConverter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ReflexToQ3/includes/EntityConverter.cpp b/ReflexToQ3/includes/EntityConverter.cpp index 55b8bea..709c939 100644 --- a/ReflexToQ3/includes/EntityConverter.cpp +++ b/ReflexToQ3/includes/EntityConverter.cpp @@ -412,6 +412,7 @@ EntityConverter::convertTarget(std::vector &lines) bool haveName = false; bool haveAngle = false; + if ( lines.size() < 3 ) { throw std::runtime_error("error: Target entity requires at least 3 lines"); } @@ -469,9 +470,12 @@ EntityConverter::convertTarget(std::vector &lines) oss3 << "\"angle\" \"" << angle << "\"\n"; convertedLines.push_back (oss3.str() ); } + return convertedLines; + } + else { + throw std::runtime_error("error: Target entity requires position coordinates and targetname"); } - return convertedLines; }