Browse Source

Fixes for memory issues detected by valgrind

merge-requests/141/head
Térence Clastres 1 year ago
committed by Adam Honse
parent
commit
53379c5482
  1. 5
      Controllers/EKController/EKController.cpp
  2. 4
      Controllers/EKController/EKControllerDetect.cpp
  3. 3
      Controllers/GloriousModelOController/GloriousModelOControllerDetect.cpp
  4. 14
      NetworkClient.cpp
  5. 1
      NetworkClient.h
  6. 2
      ProfileManager.cpp
  7. 1
      RGBController/RGBController.cpp
  8. 2
      RGBController/RGBController.h
  9. 5
      RGBController/RGBController_AuraSMBus.cpp
  10. 1
      RGBController/RGBController_AuraSMBus.h
  11. 3
      ResourceManager.cpp
  12. 5
      i2c_smbus/i2c_smbus.cpp
  13. 2
      i2c_smbus/i2c_smbus.h
  14. 2
      i2c_smbus/i2c_smbus_linux.cpp
  15. 2
      net_port/net_port.cpp
  16. 3
      serial_port/find_usb_serial_port_linux.cpp
  17. 46
      super_io/super_io.cpp

5
Controllers/EKController/EKController.cpp

@ -33,7 +33,10 @@ EKController::EKController(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_d
EKController::~EKController()
{
hid_close(dev);
if(dev)
{
hid_close(dev);
}
}
char* EKController::GetDeviceName()

4
Controllers/EKController/EKControllerDetect.cpp

@ -31,11 +31,11 @@ static const unsigned int ek_pids[][2] =
void DetectEKControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device_info* info = NULL;
//Look for the passed in cm_pids
hid_init();
info = hid_enumerate(0x0, 0x0);
info = hid_enumerate(EK_VID, 0x0);
while(info)
{

3
Controllers/GloriousModelOController/GloriousModelOControllerDetect.cpp

@ -22,9 +22,6 @@ void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controller
hid_device* dev = NULL;
hid_init();
dev = NULL;
info = hid_enumerate(Glorious_Model_O_VID, Glorious_Model_O_PID);
//Look for Glorious Model O

14
NetworkClient.cpp

@ -31,6 +31,7 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
{
strcpy(port_ip, "127.0.0.1");
port_num = OPENRGB_SDK_PORT;
client_sock = -1;
server_connected = false;
server_controller_count = 0;
@ -38,6 +39,11 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
ConnectionThread = NULL;
}
NetworkClient::~NetworkClient()
{
delete ConnectionThread;
}
void NetworkClient::ClientInfoChanged()
{
ClientInfoChangeMutex.lock();
@ -129,8 +135,12 @@ void NetworkClient::StopClient()
server_connected = false;
client_active = false;
shutdown(client_sock, SD_RECEIVE);
closesocket(client_sock);
if (server_connected)
{
shutdown(client_sock, SD_RECEIVE);
closesocket(client_sock);
}
if(ListenThread)
ListenThread->join();
ConnectionThread->join();

1
NetworkClient.h

@ -21,6 +21,7 @@ class NetworkClient
{
public:
NetworkClient(std::vector<RGBController *>& control);
~NetworkClient();
void ClientInfoChanged();

2
ProfileManager.cpp

@ -103,7 +103,7 @@ bool ProfileManager::LoadProfileWithOptions
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
char header_string[16]{};
unsigned int header_version;
controller_file.read(header_string, 16);

1
RGBController/RGBController.cpp

@ -13,6 +13,7 @@ RGBController::~RGBController()
{
DeviceThreadRunning = false;
DeviceCallThread->join();
delete DeviceCallThread;
/*---------------------------------------------------------*\
| Delete the matrix map |

2
RGBController/RGBController.h

@ -158,7 +158,7 @@ public:
| RGBController base class constructor |
\*---------------------------------------------------------*/
RGBController();
~RGBController();
virtual ~RGBController();
/*---------------------------------------------------------*\
| Generic functions implemented in RGBController.cpp |

5
RGBController/RGBController_AuraSMBus.cpp

@ -207,6 +207,11 @@ RGBController_AuraSMBus::RGBController_AuraSMBus(AuraSMBusController * aura_ptr)
active_mode = GetDeviceMode();
}
RGBController_AuraSMBus::~RGBController_AuraSMBus()
{
delete aura;
}
void RGBController_AuraSMBus::SetupZones()
{
std::vector<int> aura_led_map;

1
RGBController/RGBController_AuraSMBus.h

@ -16,6 +16,7 @@ class RGBController_AuraSMBus : public RGBController
{
public:
RGBController_AuraSMBus(AuraSMBusController* aura_ptr);
~RGBController_AuraSMBus();
void SetupZones();

3
ResourceManager.cpp

@ -34,6 +34,9 @@ ResourceManager::~ResourceManager()
{
//delete bus;
}
DetectDevicesThread->join();
delete DetectDevicesThread;
}
void ResourceManager::RegisterI2CBus(i2c_smbus_interface *bus)

5
i2c_smbus/i2c_smbus.cpp

@ -27,6 +27,11 @@ i2c_smbus_interface::i2c_smbus_interface()
i2c_smbus_thread = new std::thread(&i2c_smbus_interface::i2c_smbus_thread_function, this);
}
i2c_smbus_interface::~i2c_smbus_interface()
{
delete i2c_smbus_thread;
}
s32 i2c_smbus_interface::i2c_smbus_write_quick(u8 addr, u8 value)
{
return i2c_smbus_xfer_call(addr, value, 0, I2C_SMBUS_QUICK, NULL);

2
i2c_smbus/i2c_smbus.h

@ -66,7 +66,7 @@ public:
int pci_subsystem_vendor;
i2c_smbus_interface();
virtual ~i2c_smbus_interface() = default;
virtual ~i2c_smbus_interface();
void i2c_smbus_thread_function();

2
i2c_smbus/i2c_smbus_linux.cpp

@ -54,6 +54,7 @@ void i2c_smbus_linux_detect(std::vector<i2c_smbus_interface*> &busses)
if(dir == NULL)
{
closedir(dir);
return;
}
@ -172,6 +173,7 @@ void i2c_smbus_linux_detect(std::vector<i2c_smbus_interface*> &busses)
}
ent = readdir(dir);
}
closedir(dir);
}
REGISTER_I2C_BUS_DETECTOR(i2c_smbus_linux_detect);

2
net_port/net_port.cpp

@ -36,7 +36,7 @@ net_port::net_port(const char * client_name, const char * port)
net_port::~net_port()
{
freeaddrinfo(result_list);
}
bool net_port::udp_client(const char * client_name, const char * port)

3
serial_port/find_usb_serial_port_linux.cpp

@ -33,6 +33,7 @@ std::vector<std::string *> find_usb_serial_port(unsigned short vid, unsigned sho
if(dir == NULL)
{
closedir(dir);
return ret_vector;
}
@ -122,6 +123,8 @@ std::vector<std::string *> find_usb_serial_port(unsigned short vid, unsigned sho
ent = readdir(dir);
}
closedir(dir);
return ret_vector;
} /* find_usb_serial_port() */

46
super_io/super_io.cpp

@ -36,11 +36,15 @@ void superio_enter(int ioreg)
#else
unsigned char temp = 0x87;
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1);
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1);
close(dev_port_fd);
if (dev_port_fd >= 0)
{
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1);
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1);
close(dev_port_fd);
}
#endif
}
@ -60,10 +64,14 @@ void superio_outb(int ioreg, int reg, int val)
Out32(ioreg + 1, val);
#else
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1);
write(dev_port_fd, &val, 1);
close(dev_port_fd);
if (dev_port_fd >= 0)
{
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1);
write(dev_port_fd, &val, 1);
close(dev_port_fd);
}
#endif
}
@ -82,12 +90,20 @@ int superio_inb(int ioreg, int reg)
Out32(ioreg, reg);
return Inp32(ioreg + 1);
#else
unsigned char temp;
unsigned char temp = 0;
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1);
read(dev_port_fd, &temp, 1);
close(dev_port_fd);
return((int)temp);
if (dev_port_fd >= 0)
{
lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1);
read(dev_port_fd, &temp, 1);
close(dev_port_fd);
return((int)temp);
}
else
{
return -1;
}
#endif
}

Loading…
Cancel
Save