fix memory alloc issue
This commit is contained in:
parent
189e148829
commit
074c8ceb1d
2 changed files with 8 additions and 3 deletions
|
@ -27,7 +27,6 @@ int get_battery_level(const char *device_path, bool *is_charging) {
|
|||
}
|
||||
|
||||
unsigned char report[RAZER_REPORT_LEN] = {0};
|
||||
DWORD bytesReturned;
|
||||
|
||||
// Prepare the report to request battery information
|
||||
report[0] = RAZER_REPORT_ID_BATTERY;
|
||||
|
|
10
src/helper.c
10
src/helper.c
|
@ -29,8 +29,14 @@ void find_device_path(int pid, char *device_path) {
|
|||
SetupDiGetDeviceInterfaceDetail(hDevInfo, &deviceInterfaceData, NULL, 0,
|
||||
&requiredSize, NULL);
|
||||
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA detailData =
|
||||
(PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(requiredSize);
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA detailData;
|
||||
if (!(detailData =
|
||||
(PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(requiredSize))) {
|
||||
fprintf_s(
|
||||
stderr,
|
||||
"Failed to allocated memory for PSP_DEVICE_INTERFACE_DETAIL_DATA.\n");
|
||||
return;
|
||||
}
|
||||
detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||
|
||||
if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &deviceInterfaceData,
|
||||
|
|
Loading…
Reference in a new issue