From 00fdcc21c095cd54297f58885e5460be9ca6db70 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 14 Dec 2020 12:03:05 +0000 Subject: Add patches fixing memory leaks in Slice parser and underlying libmcpp --- dev-cpp/libmcpp/0001-Fix-memory-leaks.patch | 28 +++++++ dev-cpp/libmcpp/0002-Fix-more-memory-leaks.patch | 48 ++++++++++++ .../0001-Fix-destory-calls-in-Slice-Parser.patch | 51 +++++++++++++ .../0002-Fix-line-numbers-in-generated-code.patch | 85 ++++++++++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 dev-cpp/libmcpp/0001-Fix-memory-leaks.patch create mode 100644 dev-cpp/libmcpp/0002-Fix-more-memory-leaks.patch create mode 100644 dev-libs/slice-parser/0001-Fix-destory-calls-in-Slice-Parser.patch create mode 100644 dev-libs/slice-parser/0002-Fix-line-numbers-in-generated-code.patch diff --git a/dev-cpp/libmcpp/0001-Fix-memory-leaks.patch b/dev-cpp/libmcpp/0001-Fix-memory-leaks.patch new file mode 100644 index 0000000..bb1be6b --- /dev/null +++ b/dev-cpp/libmcpp/0001-Fix-memory-leaks.patch @@ -0,0 +1,28 @@ +From dffd7e8425064b22e6679070d216c108aef88304 Mon Sep 17 00:00:00 2001 +From: Dan Goodliffe +Date: Mon, 14 Dec 2020 11:26:14 +0000 +Subject: [PATCH 1/2] Fix memory leaks + +--- + src/main.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/main.c b/src/main.c +index f9ede32..279cbbe 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -428,8 +428,11 @@ int main + + fatal_error_exit: + #if MCPP_LIB ++ if (in_file != stdin_name) ++ free( in_file); + clear_filelist(); + clear_symtable(); ++ init_system(); + #endif + + if (fp_in && fp_in != stdin) +-- +2.29.2 + diff --git a/dev-cpp/libmcpp/0002-Fix-more-memory-leaks.patch b/dev-cpp/libmcpp/0002-Fix-more-memory-leaks.patch new file mode 100644 index 0000000..5562d83 --- /dev/null +++ b/dev-cpp/libmcpp/0002-Fix-more-memory-leaks.patch @@ -0,0 +1,48 @@ +From 201d241a756d08598bec52c044abd03bcaf2b093 Mon Sep 17 00:00:00 2001 +From: Dan Goodliffe +Date: Mon, 14 Dec 2020 11:56:33 +0000 +Subject: [PATCH 2/2] Fix more memory leaks + +--- + src/main.c | 4 ++++ + src/system.c | 2 ++ + 2 files changed, 6 insertions(+) + +diff --git a/src/main.c b/src/main.c +index 279cbbe..114b612 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -433,6 +433,10 @@ fatal_error_exit: + clear_filelist(); + clear_symtable(); + init_system(); ++ init_support(); ++ init_eval(); ++ init_directive(); ++ init_main(); + #endif + + if (fp_in && fp_in != stdin) +diff --git a/src/system.c b/src/system.c +index 91b513e..1ac380a 100644 +--- a/src/system.c ++++ b/src/system.c +@@ -3176,6 +3176,7 @@ found_name: + if (open_include( filename, (delim == '"'), next)) { + /* 'fname' should not be free()ed, it is used as file-> */ + /* real_fname and has been registered into fnamelist[] */ ++ free( filename); + return TRUE; + } + +@@ -3511,6 +3512,7 @@ search: + put_depend( fullname); /* Output dependency line */ + + true: ++ free( fullname); + return TRUE; + false: + free( fullname); +-- +2.29.2 + diff --git a/dev-libs/slice-parser/0001-Fix-destory-calls-in-Slice-Parser.patch b/dev-libs/slice-parser/0001-Fix-destory-calls-in-Slice-Parser.patch new file mode 100644 index 0000000..22361c1 --- /dev/null +++ b/dev-libs/slice-parser/0001-Fix-destory-calls-in-Slice-Parser.patch @@ -0,0 +1,51 @@ +From 022ff18892aea61af53633ba9c533b3399434d05 Mon Sep 17 00:00:00 2001 +From: Dan Goodliffe +Date: Mon, 14 Dec 2020 01:49:47 +0000 +Subject: [PATCH 1/2] Fix destory calls in Slice Parser + +--- + cpp/src/Slice/Parser.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/ice/cpp/src/Slice/Parser.cpp b/ice/cpp/src/Slice/Parser.cpp +index 8843aeddb0..312b0f3085 100644 +--- a/ice/cpp/src/Slice/Parser.cpp ++++ b/ice/cpp/src/Slice/Parser.cpp +@@ -3505,7 +3505,7 @@ void + Slice::ClassDecl::destroy() + { + _definition = 0; +- SyntaxTreeBase::destroy(); ++ Constructed::destroy(); + } + + ClassDefPtr +@@ -3781,6 +3781,7 @@ Slice::ClassDef::destroy() + { + _declaration = 0; + _bases.clear(); ++ Contained::destroy(); + Container::destroy(); + } + +@@ -4453,6 +4454,7 @@ void + Slice::Exception::destroy() + { + _base = 0; ++ Contained::destroy(); + Container::destroy(); + } + +@@ -5322,7 +5324,8 @@ Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, + void + Slice::Enum::destroy() + { +- SyntaxTreeBase::destroy(); ++ Constructed::destroy(); ++ Container::destroy(); + } + + bool +-- +2.29.2 + diff --git a/dev-libs/slice-parser/0002-Fix-line-numbers-in-generated-code.patch b/dev-libs/slice-parser/0002-Fix-line-numbers-in-generated-code.patch new file mode 100644 index 0000000..fde791b --- /dev/null +++ b/dev-libs/slice-parser/0002-Fix-line-numbers-in-generated-code.patch @@ -0,0 +1,85 @@ +From 2f673c4f9f2808a40dc0c29097ea60e3d3117a50 Mon Sep 17 00:00:00 2001 +From: Dan Goodliffe +Date: Mon, 14 Dec 2020 02:28:14 +0000 +Subject: [PATCH 2/2] Fix #line numbers in generated code + +--- + cpp/src/Slice/Grammar.cpp | 6 +++--- + cpp/src/Slice/Scanner.cpp | 10 +++++----- + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/ice/cpp/src/Slice/Grammar.cpp b/ice/cpp/src/Slice/Grammar.cpp +index 3cb7c833df..063e632d58 100644 +--- a/ice/cpp/src/Slice/Grammar.cpp ++++ b/ice/cpp/src/Slice/Grammar.cpp +@@ -127,7 +127,7 @@ slice_error(const char* s) + + + /* Line 371 of yacc.c */ +-#line 128 "src/Slice/Grammar.cpp" ++#line 131 "src/Slice/Grammar.cpp" + + # ifndef YY_NULL + # if defined __cplusplus && 201103L <= __cplusplus +@@ -237,7 +237,7 @@ int slice_parse (); + /* Copy the second part of user declarations. */ + + /* Line 390 of yacc.c */ +-#line 238 "src/Slice/Grammar.cpp" ++#line 241 "src/Slice/Grammar.cpp" + + #ifdef short + # undef short +@@ -4556,7 +4556,7 @@ yyreduce: + + + /* Line 1792 of yacc.c */ +-#line 4557 "src/Slice/Grammar.cpp" ++#line 4560 "src/Slice/Grammar.cpp" + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires +diff --git a/ice/cpp/src/Slice/Scanner.cpp b/ice/cpp/src/Slice/Scanner.cpp +index f9bb314f51..9f2aee79e7 100644 +--- a/ice/cpp/src/Slice/Scanner.cpp ++++ b/ice/cpp/src/Slice/Scanner.cpp +@@ -1,7 +1,7 @@ + #include +-#line 2 "src/Slice/Scanner.cpp" ++#line 3 "src/Slice/Scanner.cpp" + +-#line 4 "src/Slice/Scanner.cpp" ++#line 5 "src/Slice/Scanner.cpp" + + #define YY_INT_ALIGNED short int + +@@ -626,7 +626,7 @@ int checkIdentifier(string&); + + + +-#line 626 "src/Slice/Scanner.cpp" ++#line 630 "src/Slice/Scanner.cpp" + + #define INITIAL 0 + #define BOMSCAN 1 +@@ -816,7 +816,7 @@ YY_DECL + #line 93 "src/Slice/Scanner.l" + + +-#line 816 "src/Slice/Scanner.cpp" ++#line 820 "src/Slice/Scanner.cpp" + + if ( !(yy_init) ) + { +@@ -1403,7 +1403,7 @@ YY_RULE_SETUP + #line 527 "src/Slice/Scanner.l" + ECHO; + YY_BREAK +-#line 1403 "src/Slice/Scanner.cpp" ++#line 1407 "src/Slice/Scanner.cpp" + case YY_STATE_EOF(INITIAL): + case YY_STATE_EOF(BOMSCAN): + case YY_STATE_EOF(MAINSCAN): +-- +2.29.2 + -- cgit v1.2.3