Author: dchapyshev
Date: Sat Jun 6 12:14:11 2009
New Revision: 41295
URL:
http://svn.reactos.org/svn/reactos?rev=41295&view=rev
Log:
SearchPathA()
- Fix calculation of buffer size (fixes Skype crash)
Patch by Mikhail Denisenko (denisenkom(a)gmail.com)
See issue #4526 for more details.
Modified:
trunk/reactos/dll/win32/kernel32/file/dir.c
Modified: trunk/reactos/dll/win32/kernel32/file/dir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/di…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] Sat Jun 6 12:14:11 2009
@@ -885,7 +885,7 @@
goto Cleanup;
}
- BufferU.MaximumLength = (USHORT)nBufferLength * sizeof(WCHAR);
+ BufferU.MaximumLength = min(nBufferLength * sizeof(WCHAR), USHRT_MAX);
BufferU.Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
0,
BufferU.MaximumLength);
@@ -895,7 +895,7 @@
goto Cleanup;
}
- Buffer.MaximumLength = (USHORT)nBufferLength;
+ Buffer.MaximumLength = min(nBufferLength, USHRT_MAX);
Buffer.Buffer = lpBuffer;
RetValue = SearchPathW (NULL == lpPath ? NULL : PathU.Buffer,