Code enhancements mem leaks and uninitialized byte 4.99.5 eel/4.99.5 eel_4.99.5
authorRomain Forlot <romain.forlot@iot.bzh>
Thu, 21 Dec 2017 12:45:58 +0000 (13:45 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 21 Dec 2017 12:45:58 +0000 (13:45 +0100)
Change-Id: I40632b6212118278f5877957a480122e9383e3bc
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
low-can-binding/diagnostic/diagnostic-manager.cpp
low-can-binding/diagnostic/diagnostic-manager.hpp
low-can-binding/utils/socketcan.cpp

index 8533503..0454a7e 100644 (file)
@@ -36,6 +36,19 @@ diagnostic_manager_t::diagnostic_manager_t()
        : initialized_{false}
 {}
 
+
+diagnostic_manager_t::~diagnostic_manager_t()
+{
+       for(auto r: recurring_requests_)
+       {
+               delete(r);
+       }
+       for(auto r: non_recurring_requests_)
+       {
+               delete(r);
+       }
+}
+
 /// @brief Diagnostic manager isn't initialized at launch but after
 ///  CAN bus devices initialization. For the moment, it is only possible
 ///  to have 1 diagnostic bus which are the first bus declared in the JSON
index b503a06..1a6ae7e 100644 (file)
@@ -59,6 +59,7 @@ private:
        static void shims_timer();
 public:
        diagnostic_manager_t();
+       ~diagnostic_manager_t();
 
        bool initialize();
 
index 71588a6..b943d1d 100644 (file)
@@ -29,7 +29,9 @@ namespace utils
        /// @brief Construct a default, invalid, socket.
        socketcan_t::socketcan_t()
                : socket_{INVALID_SOCKET}
-       {}
+       {
+               ::memset(&tx_address_, 0, sizeof(tx_address_));
+       }
 
        /// @brief Construct a socket by moving an existing one.
        socketcan_t::socketcan_t(socketcan_t&& s)
@@ -94,4 +96,4 @@ namespace utils
        {
                return socket_;
        }
-}
\ No newline at end of file
+}