简体   繁体   中英

Debug error R6010

I've already searched online and none of it helped me. This is the code that's causing the error: Edited to include more code. Gives me the R6010 debug error in Visual Studio 2013.

do
{
    rLength = recv(s1, rBuf, 1, 0);
    if (rLength > 0)
    {
        rData += rBuf[0];
        if (rBuf[0] == nByte[0])
        {
            switch (rData[0])
            {
            case 'C':
                uid = rData.substr(1, 3);
                statSend = "00" + uid + "ST" + userinfo;
                charStat = statSend.c_str();
                lLength = send(s1, charStat, strlen(charStat) + 1, 0);
                break;
            case 'M':
                if (rData[4] == 'C' && rData[5] == 'H');
                {
                    size_t start = 6;
                    size_t end = rData.find("!@#$!@#&!@#*LlL");
                    size_t start2 = rData.find("*LlL");
                    size_t end2 = rData.find(";");

                    cout << rData.substr(start2, end2 - start2) << ":" << rData.substr(start, end - start) << endl;
                }
                break;
            }
            rData = "";
        }
    }
} while (rLength > 0);

This is a guess from what I can infer from your code. When you call

rData.find("!@#$!@#&!@#*LlL"); 

...but it doesn't find that substring, then the variable start could be set to a random value. (In my test program it was a huge integer.)

Then later you try to USE the (undefined) value stored in start to parse through the string again.

I suspect that's what you're seeing... an "out-of-bounds" error. See also this question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM