Don't attempt to allocate null-size buffer when copying empty string.

Note to next generations students: test your code and DON'T LEAK MEMORY!!!!
It still leaks atm, will have a look later on.
Note to Mr Bragin, beloved ReactOS Project Coordinator: did you actually reviewed your students work?

CORE-7272

svn path=/trunk/; revision=67885
This commit is contained in:
Pierre Schweitzer
2015-05-24 17:31:49 +00:00
parent 4c9b6600ea
commit 0d763e60fb
+11 -3
View File
@@ -33,9 +33,16 @@ PUNICODE_STRING CopyUS(PUNICODE_STRING a)
ok(b != NULL, "US is NULL after allocated memory\n");
b->Length = 0;
b->MaximumLength =a->MaximumLength;
b->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, b->MaximumLength, 1633);
ok(b->Buffer != NULL, "US->Buffer is NULL after allocated memory\n");
RtlCopyUnicodeString(b, a);
if (b->MaximumLength)
{
b->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, b->MaximumLength, 1633);
ok(b->Buffer != NULL, "US->Buffer is NULL after allocated memory\n");
RtlCopyUnicodeString(b, a);
}
else
{
b->Buffer = NULL;
}
return b;
}
@@ -147,6 +154,7 @@ START_TEST(FsRtlTunnel)
TestFsRtlAddToTunnelCache(12345, s_name, l_name, TRUE);
TestFsRtlAddToTunnelCache(12347, s_name, l_name, TRUE);
a = (PUNICODE_STRING)ExAllocatePool(PagedPool,sizeof(UNICODE_STRING));
RtlInitUnicodeString(a, NULL);
TestFsRtlAddToTunnelCache(12346, a, l_name, FALSE);
//Clear all