From ec7ed1707820ac237b5de8a4d29f522e46e39b25 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Wed, 27 Jan 2016 19:31:31 +0100
Subject: [PATCH] Fixed parse of cmd string

Before this fix, using cmd() with an erroneous string was triggering
no error. Now this is fixed.

Notice that this is an old bug (introduced in 0a46f15d).
It should be harmless when using MD codes with proper interfaces.
---
 src/core/PlumedMain.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index a9e372afe..37ea9d904 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -171,7 +171,10 @@ void PlumedMain::cmd(const std::string & word,void*val){
   std::vector<std::string> words=Tools::getWords(word);
   unsigned nw=words.size();
   if(nw==1) {
-    switch(word_map[word]) {
+    int iword=-1;
+    std::map<std::string, int>::const_iterator it=word_map.find(word);
+    if(it!=word_map.end()) iword=it->second;
+    switch(iword) {
       double d;
       case SETBOX:
         CHECK_INIT(initialized,word);
-- 
GitLab