From 986ffd51aa9f276c8a0e854aaf3e609f115cd4f8 Mon Sep 17 00:00:00 2001 From: Mahesh Madhav Date: Mon, 5 Aug 2024 21:55:12 +0000 Subject: [PATCH 1/5] Fix memory safety issue in slistartup.cc Also fixes the memory leak in parser.h --- sli/parser.h | 3 ++- sli/slistartup.cc | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sli/parser.h b/sli/parser.h index dc5d67aae9..75b5009128 100644 --- a/sli/parser.h +++ b/sli/parser.h @@ -38,7 +38,7 @@ class Parser { - Scanner* s; + Scanner* s = nullptr; Token arraytoken; Token proctoken; @@ -61,6 +61,7 @@ class Parser public: Parser(); Parser( std::istream& ); + ~Parser() { if (s) delete s; } bool operator()( Token& ); bool diff --git a/sli/slistartup.cc b/sli/slistartup.cc index 61dcd706cb..982a0692e9 100644 --- a/sli/slistartup.cc +++ b/sli/slistartup.cc @@ -214,53 +214,55 @@ SLIStartup::SLIStartup( int argc, char** argv ) StringDatum* sd = new StringDatum( argv[ i ] ); args_array.push_back( Token( sd ) ); - if ( *sd == "-d" or *sd == "--debug" ) + std::string myarg = argv[i]; + + if ( myarg == "-d" or myarg == "--debug" ) { debug_ = true; verbosity_ = SLIInterpreter::M_ALL; // make the interpreter verbose. continue; } - if ( *sd == "--verbosity=ALL" ) + if ( myarg == "--verbosity=ALL" ) { verbosity_ = SLIInterpreter::M_ALL; continue; } - if ( *sd == "--verbosity=DEBUG" ) + if ( myarg == "--verbosity=DEBUG" ) { verbosity_ = SLIInterpreter::M_DEBUG; continue; } - if ( *sd == "--verbosity=STATUS" ) + if ( myarg == "--verbosity=STATUS" ) { verbosity_ = SLIInterpreter::M_STATUS; continue; } - if ( *sd == "--verbosity=INFO" ) + if ( myarg == "--verbosity=INFO" ) { verbosity_ = SLIInterpreter::M_INFO; continue; } - if ( *sd == "--verbosity=DEPRECATED" ) + if ( myarg == "--verbosity=DEPRECATED" ) { verbosity_ = SLIInterpreter::M_DEPRECATED; continue; } - if ( *sd == "--verbosity=WARNING" ) + if ( myarg == "--verbosity=WARNING" ) { verbosity_ = SLIInterpreter::M_WARNING; continue; } - if ( *sd == "--verbosity=ERROR" ) + if ( myarg == "--verbosity=ERROR" ) { verbosity_ = SLIInterpreter::M_ERROR; continue; } - if ( *sd == "--verbosity=FATAL" ) + if ( myarg == "--verbosity=FATAL" ) { verbosity_ = SLIInterpreter::M_FATAL; continue; } - if ( *sd == "--verbosity=QUIET" ) + if ( myarg == "--verbosity=QUIET" ) { verbosity_ = SLIInterpreter::M_QUIET; continue; From 137b1cdce597a7b675a4048640723602aa1f50e6 Mon Sep 17 00:00:00 2001 From: Mahesh Madhav Date: Wed, 14 Aug 2024 22:44:40 +0000 Subject: [PATCH 2/5] Fix pedantic error for ISO C++ error: ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~' [-Werror,-Wdtor-name] --- nestkernel/connection_creator_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nestkernel/connection_creator_impl.h b/nestkernel/connection_creator_impl.h index 7aa224347f..e094ab59d5 100644 --- a/nestkernel/connection_creator_impl.h +++ b/nestkernel/connection_creator_impl.h @@ -167,7 +167,7 @@ ConnectionCreator::PoolWrapper_< D >::PoolWrapper_() } template < int D > -ConnectionCreator::PoolWrapper_< D >::~PoolWrapper_() +ConnectionCreator::PoolWrapper_< D >::~PoolWrapper_< D >() { if ( masked_layer_ ) { From 8f92cdebc63b5775b8e791b7dc8bdd8d909b1554 Mon Sep 17 00:00:00 2001 From: Mahesh Madhav <67384846+heshpdx@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:36:35 -0700 Subject: [PATCH 3/5] Update sli/parser.h Co-authored-by: Hans Ekkehard Plesser --- sli/parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/parser.h b/sli/parser.h index 75b5009128..4bd1aff33a 100644 --- a/sli/parser.h +++ b/sli/parser.h @@ -61,7 +61,7 @@ class Parser public: Parser(); Parser( std::istream& ); - ~Parser() { if (s) delete s; } + ~Parser() { delete s; } bool operator()( Token& ); bool From 3ee5e11d764d20bdad45be8fae2425bdaeb3b88d Mon Sep 17 00:00:00 2001 From: Mahesh Madhav <67384846+heshpdx@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:36:41 -0700 Subject: [PATCH 4/5] Update sli/slistartup.cc Co-authored-by: Hans Ekkehard Plesser --- sli/slistartup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/slistartup.cc b/sli/slistartup.cc index 982a0692e9..a090c701f9 100644 --- a/sli/slistartup.cc +++ b/sli/slistartup.cc @@ -214,7 +214,7 @@ SLIStartup::SLIStartup( int argc, char** argv ) StringDatum* sd = new StringDatum( argv[ i ] ); args_array.push_back( Token( sd ) ); - std::string myarg = argv[i]; + const std::string myarg = argv[ i ]; if ( myarg == "-d" or myarg == "--debug" ) { From d45c5e408d52496e192b5321d9ec7d96d296f3c2 Mon Sep 17 00:00:00 2001 From: Hans Ekkehard Plesser Date: Mon, 19 Aug 2024 11:15:19 +0200 Subject: [PATCH 5/5] Update sli/parser.h --- sli/parser.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sli/parser.h b/sli/parser.h index 4bd1aff33a..79f70bcba4 100644 --- a/sli/parser.h +++ b/sli/parser.h @@ -61,7 +61,10 @@ class Parser public: Parser(); Parser( std::istream& ); - ~Parser() { delete s; } + ~Parser() + { + delete s; + } bool operator()( Token& ); bool