jeudi 30 juin 2016

C++11 vector insert causes invalid access

I'm writing a DLL for some features and seeing a strange problem. If I use the below code in my DLL and try to load it, it throws the error:

// Sample code
uint8_t data[SIZE_MAX]; // SIZE_MAX = 15
std::vector<uint8_t> v(data, data + SIZE_MAX);
// more code
std::vector<uint8_t> appendData; // initialize it with some value
v.insert(v.end(), appendData.begin(), appendData.end());

ERROR:
LoadLibraryW failed with error (3E6): Invalid access to memory location.

I have been using the same code for a while and it always worked. However, it stopped working suddenly and I'm not sure what exactly is causing this error. Any pointers?

Aucun commentaire:

Enregistrer un commentaire