@@ -60,6 +60,7 @@ bool DeviceNameResolver::resolveDeviceLongNameToShort(const TCHAR * sourcePath,
6060
6161void DeviceNameResolver::fixVirtualDevices ()
6262{
63+ const USHORT BufferSize = MAX_PATH * 2 * sizeof (WCHAR);
6364 WCHAR longCopy[MAX_PATH] = {0 };
6465 OBJECT_ATTRIBUTES oa = {0 };
6566 UNICODE_STRING unicodeInput = {0 };
@@ -68,9 +69,9 @@ void DeviceNameResolver::fixVirtualDevices()
6869 ULONG retLen = 0 ;
6970 HardDisk hardDisk;
7071
71- unicodeOutput.Length = MAX_PATH * 2 * sizeof (WCHAR );
72- unicodeOutput. MaximumLength = unicodeOutput.Length ;
73- unicodeOutput. Buffer = (PWSTR) calloc (unicodeOutput. Length , 1 ) ;
72+ unicodeOutput.Buffer = (PWSTR) malloc (BufferSize );
73+ if (! unicodeOutput.Buffer )
74+ return ;
7475
7576 for (unsigned int i = 0 ; i < deviceNameList.size (); i++)
7677 {
@@ -81,8 +82,9 @@ void DeviceNameResolver::fixVirtualDevices()
8182
8283 if (NT_SUCCESS (NativeWinApi::NtOpenSymbolicLinkObject (&hFile, SYMBOLIC_LINK_QUERY, &oa)))
8384 {
84- unicodeOutput.Length = MAX_PATH * 2 * sizeof (WCHAR) ;
85+ unicodeOutput.Length = BufferSize ;
8586 unicodeOutput.MaximumLength = unicodeOutput.Length ;
87+ ZeroMemory (unicodeOutput.Buffer , unicodeOutput.Length );
8688
8789 if (NT_SUCCESS (NativeWinApi::NtQuerySymbolicLinkObject (hFile, &unicodeOutput, &retLen)))
8890 {
0 commit comments