0

daedalus_1.4.exe 中 0x770115de 处的未处理异常:0xC0000005:访问冲突读取位置 0xccccccc0。

string temp;
string locName = "0";

vector<vector<string>> l;
int m = 100, n = 3; //vector dimension
l.resize(m);
for(int i = 0; i < m; ++i) l[i].resize(n);

temp.clear();

if(line.substr(1, 17) == "Timing LocationID" && arrayFull == true) {
    int i = 0; //starting char
    while (line[i++] != '='); //increment to next
    while (line[++i] != '"') temp += line[i];
    locName = findLocation(temp, 0, "", l);

string findLocation (string temp, int index, string locName, vector<vector<string>> &l)
{
    if (temp == "*") return locName; // <------errors here on return
    if (l[index][0] == temp) findLocation(l[index][1], 0, locName.insert(0,l[index][2]), l);
    else findLocation(temp, ++index, locName, l);
}

这个函数循环遍历一个 2xvector 并返回一个由父->子向量单元组成的连接字符串

这些来自调用堆栈;看起来像字符串析构函数

__CLR_OR_THIS_CALL ~basic_string()
    {   // destroy the string
    _Tidy(true);
    }

void __CLR_OR_THIS_CALL _Tidy(bool _Built = false,
    size_type _Newsize = 0)
    {   // initialize buffer, deallocating any storage
    if (!_Built)
        ;
    else if (_BUF_SIZE <= _Myres)
        {   // copy any leftovers to small buffer and deallocate
        _Elem *_Ptr = _Bx._Ptr;
        if (0 < _Newsize)
            _Traits_helper::copy_s<_Traits>(_Bx._Buf, _BUF_SIZE, _Ptr, _Newsize);
        _Mybase::_Alval.deallocate(_Ptr, _Myres + 1);
        }
    _Myres = _BUF_SIZE - 1;
    _Eos(_Newsize);
    }
4

1 回答 1

2

你的函数字符串 findLocation()

不会在所有路径上返回值,也许您的意思是:

string findLocation (string temp, int index, string locName, vector<vector<string>> &l)
{
    if (temp == "*") return locName;
    if (l[index][0] == temp) return findLocation(l[index][1], 0, locName.insert(0,l[index][2]), l);
    else return findLocation(temp, ++index, locName, l);
}
于 2012-07-12T23:16:06.663 回答