From 2443198f1df6c0b3b283a90c63168e770af73c59 Mon Sep 17 00:00:00 2001
From: Victor Poughon <victor.poughon@cnes.fr>
Date: Wed, 11 Oct 2017 11:43:20 +0200
Subject: [PATCH] Fix coverity #1457789

---
 .../src/otbWrapperCommandLineLauncher.cxx     | 20 +++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
index 736ad395b5..5d57a8337e 100644
--- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
+++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
@@ -817,18 +817,22 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer &
 
   if (type == ParameterType_Choice)
     {
-    std::vector<std::string> keys = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceKeys();
-    std::vector<std::string> names = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceNames();
+    ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param.GetPointer());
+    if (paramDown)
+      {
+      std::vector<std::string> keys = paramDown->GetChoiceKeys();
+      std::vector<std::string> names = paramDown->GetChoiceNames();
 
-    oss << "[";
-    for(unsigned int i=0; i<keys.size(); i++)
+      oss << "[";
+      for(unsigned int i=0; i<keys.size(); i++)
       {
-      oss<<keys[i];
-      if( i != keys.size()-1 )
-        oss << "/";
+        oss<<keys[i];
+        if( i != keys.size()-1 )
+          oss << "/";
       }
 
-    oss << "]";
+      oss << "]";
+      }
     }
 
   if(m_Application->IsMandatory(paramKey))
-- 
GitLab