Skip to content

Commit

Permalink
devsane: Make use of the new HeapSafeFree function
Browse files Browse the repository at this point in the history
  • Loading branch information
mback2k committed Jun 15, 2014
1 parent e089f17 commit 2d05622
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions devsane/devsane_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <newdev.h>

#include "strutil.h"
#include "strutil_mem.h"
#include "strutil_dbg.h"
#include "devsane_util.h"

Expand Down Expand Up @@ -107,13 +108,13 @@ DWORD CALLBACK DeviceInstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_opt_
} else
Trace(TEXT("SetupDiSetDeviceRegistryProperty failed: %08X"), res = GetLastError());

HeapFree(hHeap, 0, lpHardwareIds);
HeapSafeFree(hHeap, 0, lpHardwareIds);
} else
Trace(TEXT("StringCchAPrintf failed: %08X"), hr);
} else
Trace(TEXT("SetupDiGetDeviceInstanceId 2 failed: %08X"), res = GetLastError());

HeapFree(hHeap, 0, lpHardwareId);
HeapSafeFree(hHeap, 0, lpHardwareId);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Expand All @@ -129,15 +130,15 @@ DWORD CALLBACK DeviceInstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_opt_
} else
Trace(TEXT("SetupDiGetINFClass 2 failed: %08X"), res = GetLastError());

HeapFree(hHeap, 0, lpClassName);
HeapSafeFree(hHeap, 0, lpClassName);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Trace(TEXT("SetupDiGetINFClass 1 failed: %08X"), res = GetLastError());
} else
Trace(TEXT("DriverPackageGetPath 2 failed: %08X"), res);

HeapFree(hHeap, 0, lpDsInfPath);
HeapSafeFree(hHeap, 0, lpDsInfPath);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Expand Down Expand Up @@ -199,7 +200,7 @@ DWORD CALLBACK DeviceUninstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_opt
} else
Trace(TEXT("SetupDiGetDeviceRegistryProperty 2 failed: %08X"), res = GetLastError());

HeapFree(hHeap, 0, lpHardwareIds);
HeapSafeFree(hHeap, 0, lpHardwareIds);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Expand All @@ -216,15 +217,15 @@ DWORD CALLBACK DeviceUninstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_opt
} else
Trace(TEXT("SetupDiGetINFClass 2 failed: %08X"), res = GetLastError());

HeapFree(hHeap, 0, lpClassName);
HeapSafeFree(hHeap, 0, lpClassName);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Trace(TEXT("SetupDiGetINFClass 1 failed: %08X"), res = GetLastError());
} else
Trace(TEXT("DriverPackageGetPath 2 failed: %08X"), res);

HeapFree(hHeap, 0, lpDsInfPath);
HeapSafeFree(hHeap, 0, lpDsInfPath);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Expand Down
7 changes: 4 additions & 3 deletions devsane/devsane_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <difxapi.h>

#include "strutil.h"
#include "strutil_mem.h"
#include "strutil_dbg.h"
#include "devsane_util.h"

Expand All @@ -49,7 +50,7 @@ DWORD DriverInstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_ int nCmdShow)
if (res != ERROR_SUCCESS && res != ERROR_NO_SUCH_DEVINST)
Trace(TEXT("DriverPackageInstall failed: %08X"), res);

HeapFree(hHeap, 0, lpData);
HeapSafeFree(hHeap, 0, lpData);
}

return res;
Expand Down Expand Up @@ -86,12 +87,12 @@ DWORD DriverUninstall(_In_ HANDLE hHeap, _In_ LPTSTR lpInfPath, _In_ int nCmdSho
if (res != ERROR_SUCCESS)
Trace(TEXT("DriverPackageUninstall failed: %08X"), res);

HeapFree(hHeap, 0, lpData);
HeapSafeFree(hHeap, 0, lpData);
}
} else
Trace(TEXT("DriverPackageGetPath 2 failed: %08X"), res);

HeapFree(hHeap, 0, lpDsInfPath);
HeapSafeFree(hHeap, 0, lpDsInfPath);
} else
Trace(TEXT("HeapAlloc failed"));
} else
Expand Down

0 comments on commit 2d05622

Please sign in to comment.