Skip to content
Snippets Groups Projects
Commit 922bbcea authored by Jan Trávníček's avatar Jan Trávníček
Browse files

cli: fix undefined behavior in dot algo

parent 3aa3c5f2
No related branches found
No related tags found
1 merge request!200clang tidy fixes
Pipeline #163625 passed with warnings
......@@ -65,15 +65,14 @@ void Dot::dot2 ( const std::string & data ) {
dot ( data, true );
}
 
void Dot::dot ( const std::string & data, const std::string& outputType, const std::string & outputFile ) {
std::string outputTypeLower;
std::transform ( outputType.begin ( ), outputType.end ( ), outputTypeLower.begin ( ), ::tolower );
void Dot::dot ( const std::string & data, std::string outputType, const std::string & outputFile ) {
std::transform ( outputType.begin ( ), outputType.end ( ), outputType.begin ( ), ::tolower );
 
if ( std::find ( allowedOutputTypes.begin( ), allowedOutputTypes.end ( ), outputTypeLower ) == allowedOutputTypes.end ( ) ) {
throw exception::CommonException ( "Dot: Invalid output type." );
if ( std::find ( allowedOutputTypes.begin( ), allowedOutputTypes.end ( ), outputType ) == allowedOutputTypes.end ( ) ) {
throw exception::CommonException ( "Dot: Invalid output type (" + outputType + ")." );
}
 
run ( data, outputTypeLower, outputFile, false );
run ( data, outputType, outputFile, false );
}
 
 
......@@ -89,7 +88,7 @@ auto DotTx11 = registration::AbstractRegister < Dot, void, const std::string &,
@param dot a string containing dot data\n\
@param background a flag specifying whether to run in background (does not block CLI input)" );
 
auto DotFile = registration::AbstractRegister < Dot, void, const std::string &, const std::string &, const std::string & > ( Dot::dot, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "data", "outputType", "outputFile" ).setDocumentation (
auto DotFile = registration::AbstractRegister < Dot, void, const std::string &, std::string, const std::string & > ( Dot::dot, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, "data", "outputType", "outputFile" ).setDocumentation (
"Cli builtin command for DOT format visualization. Runs dot -T<outputType> -o <outputFile> and blocks the input until done.\n\
\n\
@param data a string containing dot data\n\
......
......@@ -34,7 +34,7 @@ public:
* \param outputType the type of dot created image
* \param outputFile the destination file name
*/
static void dot ( const std::string & data, const std::string & outputType, const std::string & outputFile );
static void dot ( const std::string & data, std::string outputType, const std::string & outputFile );
 
protected:
/** Allowed output types */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment