Vector Expression out of Ranged or Standard C++ Libraries Out of Range" && 0

Jul 20, 2014 at 8:33 PM
Edited Jul 20, 2014 at 8:48 PM
Here is my code snippet:

IStream *spFileStream;
HGLOBAL hMem;
//std::shared_ptr<AppCredentials> appcreds = std::make_shared<AppCredentials>();
DWORD length;
std::vector<uint8_t> body;
RestApi rest(body, length);  //my api which takes input parameters for calling webservices
//  HGLOBAL hMem;

LPVOID pData = NULL;
hMem = GlobalAlloc(GMEM_MOVEABLE, length);
//IStream *m;
pData = GlobalLock(hMem);
memcpy(pData, &body[0], length);
GlobalUnlock(hMem);
std::cout << "\n length:" << length;
__int64 i = 0;
LARGE_INTEGER li;
li.QuadPart = i;
HRESULT hr = CreateStreamOnHGlobal(hMem, FALSE, &spFileStream);
spFileStream->Seek(li, STREAM_SEEK_SET, NULL);




After running this code i am getting error:

Program: C:\WINDOWS\SYSTEM32\MSVCP120D.dll
File: c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector
Line: 1201

Expression: vector subscript out of range

After i ignore the previous error, i get another one:

File: c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector
Line: 1202

Expression: "Standard C++ Libraries Out of Range" && 0

After ignoring above error, program breaks at :

memcpy(pData, &body[0], length);
Unhandled exception at 0x5087A893 (msvcr120d.dll) in downloadFile.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
Coordinator
Jul 21, 2014 at 4:34 PM
Does your app work if you remove the RestAPI class construction and just fill the vector with some simple values? What is the size of the vector since the first exception indicates your going out of bounds on the vector? It doesn't look like the C++ Rest SDK is necessarily anything to do with your problem here.

Steve