View Issue Details

IDProjectCategoryView StatusLast Update
0007063ardourbugspublic2016-10-07 17:52
Reporternstewart Assigned Tox42  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformallOSall 
Product Version5.X git (version in description) 
Summary0007063: SysEx class can leak _flag member
Descriptioncppcheck indicates that the SysEx class can leak the _flag member, and lacks a copy constructor. It doesn't appear to ever be copied (I made a private copy constructor and was able to compile.) I also added a destructor to free allocated memory and suppress the warning.
Additional Information[gtk2_ardour/sys_ex.h:48]: (style) Unused private function: SysEx::event_handler'
[gtk2_ardour/sys_ex.h:29]: (style) 'class SysEx' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
[gtk2_ardour/sys_ex.h:50]: (style) Class 'SysEx' is unsafe, 'SysEx::_flag' can leak by wrong usage.

======================
From 6bf7fee813e9d1f159c33c9049451f78ddc475a4 Mon Sep 17 00:00:00 2001
From: Nathan Stewart <therealnathanstewart@gmail.com>
Date: Fri, 7 Oct 2016 12:38:00 -0400
Subject: [PATCH] Clean up cppcheck warnings about handling of allocated memory
 in SysEx class

---
 gtk2_ardour/sys_ex.cc | 2 ++
 gtk2_ardour/sys_ex.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/gtk2_ardour/sys_ex.cc b/gtk2_ardour/sys_ex.cc
index b625193..f3e02b1 100644
--- a/gtk2_ardour/sys_ex.cc
+++ b/gtk2_ardour/sys_ex.cc
@@ -45,6 +45,8 @@ SysEx::SysEx (
 
 SysEx::~SysEx()
 {
+ delete _flag;
+ _flag = 0;
 }
 
 bool
diff --git a/gtk2_ardour/sys_ex.h b/gtk2_ardour/sys_ex.h
index 709841c..1290482 100644
--- a/gtk2_ardour/sys_ex.h
+++ b/gtk2_ardour/sys_ex.h
@@ -46,7 +46,7 @@ public:
 
 private:
     bool event_handler (GdkEvent* ev);
-
+ SysEx(const SysEx& rhs){}
     ArdourCanvas::Flag* _flag;
 };
 
--
2.7.4
TagsNo tags attached.

Activities

nstewart

2016-10-07 17:46

reporter  

0001-Clean-up-cppcheck-warnings-about-handling-of-allocat.patch (904 bytes)   
From 6bf7fee813e9d1f159c33c9049451f78ddc475a4 Mon Sep 17 00:00:00 2001
From: Nathan Stewart <therealnathanstewart@gmail.com>
Date: Fri, 7 Oct 2016 12:38:00 -0400
Subject: [PATCH] Clean up cppcheck warnings about handling of allocated memory
 in SysEx class

---
 gtk2_ardour/sys_ex.cc | 2 ++
 gtk2_ardour/sys_ex.h  | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/gtk2_ardour/sys_ex.cc b/gtk2_ardour/sys_ex.cc
index b625193..f3e02b1 100644
--- a/gtk2_ardour/sys_ex.cc
+++ b/gtk2_ardour/sys_ex.cc
@@ -45,6 +45,8 @@ SysEx::SysEx (
 
 SysEx::~SysEx()
 {
+	delete _flag;
+	_flag = 0;
 }
 
 bool
diff --git a/gtk2_ardour/sys_ex.h b/gtk2_ardour/sys_ex.h
index 709841c..1290482 100644
--- a/gtk2_ardour/sys_ex.h
+++ b/gtk2_ardour/sys_ex.h
@@ -46,7 +46,7 @@ public:
 
 private:
 	bool event_handler (GdkEvent* ev);
-
+	SysEx(const SysEx& rhs){}
 	ArdourCanvas::Flag* _flag;
 };
 
-- 
2.7.4

x42

2016-10-07 17:52

administrator   ~0018779

applied as Ardour 5.4-63-g59cc0a1 Thanks

Issue History

Date Modified Username Field Change
2016-10-07 16:39 nstewart New Issue
2016-10-07 17:46 nstewart File Added: 0001-Clean-up-cppcheck-warnings-about-handling-of-allocat.patch
2016-10-07 17:52 x42 Note Added: 0018779
2016-10-07 17:52 x42 Status new => closed
2016-10-07 17:52 x42 Assigned To => x42
2016-10-07 17:52 x42 Resolution open => fixed