mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 06:46:06 +00:00
Check for failed allocations. Spotted by Martin Bealby.
svn path=/trunk/; revision=20092
This commit is contained in:
parent
592fc91d75
commit
10177cfd7f
1 changed files with 7 additions and 66 deletions
|
@ -290,72 +290,6 @@ RtlSetCurrentDirectory_U(PUNICODE_STRING dir)
|
||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* What the heck is this all about??? It looks like its getting the long path,
|
|
||||||
* and if does, ITS WRONG! If current directory is set with a short path,
|
|
||||||
* GetCurrentDir should return a short path.
|
|
||||||
* If anyone agrees with me, remove this stuff.
|
|
||||||
* -Gunnar
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
filenameinfo = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
MAX_PATH*sizeof(WCHAR)+sizeof(ULONG));
|
|
||||||
|
|
||||||
Status = ZwQueryInformationFile(handle,
|
|
||||||
&iosb,
|
|
||||||
filenameinfo,
|
|
||||||
MAX_PATH*sizeof(WCHAR)+sizeof(ULONG),
|
|
||||||
FileNameInformation);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
filenameinfo);
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
buf);
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
full.Buffer);
|
|
||||||
RtlReleasePebLock();
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If it's just "\", we need special handling */
|
|
||||||
if (filenameinfo->FileNameLength > sizeof(WCHAR))
|
|
||||||
{
|
|
||||||
wcs = buf + size / sizeof(WCHAR) - 1;
|
|
||||||
if (*wcs == L'\\')
|
|
||||||
{
|
|
||||||
*(wcs) = 0;
|
|
||||||
wcs--;
|
|
||||||
size -= sizeof(WCHAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Index = 0;
|
|
||||||
Index < filenameinfo->FileNameLength / sizeof(WCHAR);
|
|
||||||
Index++)
|
|
||||||
{
|
|
||||||
if (filenameinfo->FileName[Index] == '\\') backslashcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("%d \n",backslashcount);
|
|
||||||
for (;backslashcount;wcs--)
|
|
||||||
{
|
|
||||||
if (*wcs=='\\') backslashcount--;
|
|
||||||
}
|
|
||||||
wcs++;
|
|
||||||
|
|
||||||
RtlCopyMemory(wcs, filenameinfo->FileName, filenameinfo->FileNameLength);
|
|
||||||
wcs[filenameinfo->FileNameLength / sizeof(WCHAR)] = 0;
|
|
||||||
|
|
||||||
size = (wcs - buf) * sizeof(WCHAR) + filenameinfo->FileNameLength;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cd->Handle)
|
if (cd->Handle)
|
||||||
ZwClose(cd->Handle);
|
ZwClose(cd->Handle);
|
||||||
cd->Handle = handle;
|
cd->Handle = handle;
|
||||||
|
@ -547,6 +481,11 @@ static ULONG get_full_path_helper(
|
||||||
val.Length = 0;
|
val.Length = 0;
|
||||||
val.MaximumLength = size;
|
val.MaximumLength = size;
|
||||||
val.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
|
val.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
|
||||||
|
if (val.Buffer == NULL)
|
||||||
|
{
|
||||||
|
reqsize = 0;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
switch (RtlQueryEnvironmentVariable_U(NULL, &var, &val))
|
switch (RtlQueryEnvironmentVariable_U(NULL, &var, &val))
|
||||||
{
|
{
|
||||||
|
@ -713,6 +652,8 @@ DWORD NTAPI RtlGetFullPathName_U(
|
||||||
if (reqsize > size)
|
if (reqsize > size)
|
||||||
{
|
{
|
||||||
LPWSTR tmp = RtlAllocateHeap(RtlGetProcessHeap(), 0, reqsize);
|
LPWSTR tmp = RtlAllocateHeap(RtlGetProcessHeap(), 0, reqsize);
|
||||||
|
if (tmp == NULL)
|
||||||
|
return 0;
|
||||||
reqsize = get_full_path_helper(name, tmp, reqsize);
|
reqsize = get_full_path_helper(name, tmp, reqsize);
|
||||||
if (reqsize > size) /* it may have worked the second time */
|
if (reqsize > size) /* it may have worked the second time */
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue