While investigating a dump, I'm dealing with an access violation, caused by this piece of source code:
CByteArray baInput;
... // baInput gets filled in with 9804 entries
BYTE* result;
result = new BYTE[baInput.GetSize()]; // baInput.GetSize() gives 9804, as expected.
memcpy (result, &baInput, baInput.GetSize()); // access violation
In order to understand what's going on, I've added sizeof(result)
in the watch-window, which yields 8
(while I expected 9804), but I'm not sure if this is the right thing to do here.
I'd like to be really sure that the reservation of memory for the result
variable has been performed successfully. How can I do that?
Does anybody have an idea what might be going wrong here?
Thanks in advance
Oh, I forgot: I'm working on a Windows environment, most probably Windows-10.
The programming environment is based on Windows kits, version 8.1.
CByteArray
is MFC code.
I don't know if this is relevant, but the CByteArray
contains quite some backslash characters.