please look this code , in my machine , it do not raise error , but I do not understand why can I copy more bytes than VirtualAlloc allocated,is this operation safe ?
PBYTE pNewBuffer = (PBYTE) VirtualAlloc(NULL,3,MEM_COMMIT,PAGE_READWRITE);
BYTE FlagThree[] = {'a', 'b', 'c', 'd','e','f','g'};
CopyMemory(pNewBuffer,FlagThree,sizeof(FlagThree));
I allocate 3 bytes but copy to the memory 7 bytes.