QVector::operator[] segment violation mysterious.
-
Hello.
I'm working on a Encryption Algorithms test.
Specifically, this code give me the next problems:
@QString Crypto::unpermute(const QString& str){
QString sKey;
sKey.setNum(m_usKey);const int rows=str.length()/sKey.length();
QVector<QByteArray> seqTable;
int nCount=0;
int nCountPos=0;
int posKeeper=0;
QVector<QChar> keySorter;for(int i=0; i<sKey.size();++i)
keySorter.push_back(sKey[i]);
qSort(keySorter);seqTable.reserve(sKey.length());
//Fill Vector<QBA>
for(int i=0;i<sKey.length();i++){
QByteArray qbaBuffer;
//Per QBA
for(int j=0;j<rows;j++){
qbaBuffer+=str[nCount];
++nCount;
}
//Insert QBA into its respective place
for(int k=0;k<sKey.length();k++){
if(keySorter[nCountPos]==sKey[k]){
posKeeper=k;
seqTable[posKeeper]=qbaBuffer;
}
}
}QString dest;
//Read and store uncryptying string
for(int k=0;k<rows;k++)
for(int l=0;l<sKey.length();l++)
dest+=seqTable[l][k];return dest;
}@!http://i1344.photobucket.com/albums/p656/Charlie_Hdz/03_zpsc2b42b7b.png(A)!
(This is the output of Qmake;make)(Using QMake Debugger and arriving to this instruction <seqTable[posKeeper]=qbaBuffer;> , QtCreator send me this message:)
!http://i1344.photobucket.com/albums/p656/Charlie_Hdz/02_zpsac8d978a.png(2)!Any help would be appreciated.